Compare commits

...

1383 Commits

Author SHA1 Message Date
Slava Monich
54d610ce6a Merge branch 'vendor' into 'master'
MTK support

See merge request !156
2018-01-18 21:34:14 +00:00
Slava Monich
f7f9e32743 unit: Improve idmap.c unit test coverage
This brings function, line and branch coverage for idmap.c to 100%
2018-01-18 23:29:21 +02:00
Slava Monich
8c9e370486 [ril] Support for vendor extensions. JB#39612 2018-01-18 17:34:41 +02:00
Slava Monich
19b80236f6 [ofono] gprs: Add __ofono_gprs_context_settings_by_type 2018-01-18 17:34:40 +02:00
Slava Monich
2ec6fc749d [unit] Added test-sailfish_cell_info_dbus
Tests sailfish_cell_info_dbus.c

  Lines:     215/220  97.7 %
  Functions: 25/25   100.0 %
  Branches:  72/88    81.8 %
2018-01-18 13:34:41 +02:00
Slava Monich
0a3bdd20f4 [ril] Validate dbus_bool_t
libdbus crashes and burns when boolean value is not 0 or 1
2018-01-18 13:27:46 +02:00
Slava Monich
284919e76a Merge branch 'jb40756' into 'master'
Don't repeat cell info requests indefinitely

See merge request !163
2018-01-17 15:14:20 +00:00
Slava Monich
ddcbb89fa1 [ril] Don't repeat cell info requests indefinitely. Fixes JB#40756
If they fail, they typically keep on failing forever. Repeating the
requests doesn't do any good, it's just draining the battery.
2018-01-17 17:11:59 +02:00
Slava Monich
5ec6b8e7ec [test] Improve sailfish_manager.c test coverage 2018-01-04 12:09:34 +02:00
Slava Monich
f94681f6f6 Merge branch 'iccid_watch' into 'master'
Properly reset cached SIM info after removal

See merge request !162
2018-01-04 10:08:35 +00:00
Slava Monich
de8edc84fa [ofono] Properly reset cached SIM info after removal. Fixes JB#39810
sailfish_watch expected to be notified by ofono of every ICCID or IMSI
change, however it wasn't happening when SIM card was getting removed.
That messed things up.
2018-01-03 16:45:39 +02:00
Slava Monich
90faf1b3a5 Merge branch 'fac_timeout' into 'master'
Make sure SIM_IO and QUERY_FACILITY_LOCK requests get completed

See merge request !161
2018-01-02 09:40:11 +00:00
Slava Monich
2b139b6974 [ril] Make sure SIM_IO and QUERY_FACILITY_LOCK get completed
ofono becomes very unhappy if they don't. Also, completion
is required in order to eventually reset SIM I/O active flag.
If doesn't make sense to keep it on forever.
2017-12-25 18:23:57 +02:00
Slava Monich
168f193efb Merge branch 'refresh' into 'master'
Handle SIM reset

See merge request !160
2017-12-08 21:09:15 +00:00
Slava Monich
32d8b5ccfc sim: Don't submit parallel EFpl reads
In addition to not doing unnecessary SIM I/O, this fixes memory leaks
like this one:

==10096== 74 (56 direct, 18 indirect) bytes in 2 blocks are definitely lost in loss record 1,252 of 1,342
==10096==    at 0x4841BF0: calloc (vg_replace_malloc.c)
==10096==    by 0x4B03117: g_malloc0 (gmem.c)
==10096==    by 0xF83DF: concat_lang_prefs (sim.c)
==10096==    by 0xF8697: sim_efpl_read_cb (sim.c)
==10096==    by 0x12CBF7: sim_fs_op_read_block_cb (simfs.c)
2017-12-09 00:06:26 +03:00
Slava Monich
f400ceff80 Merge branch 'sms-filter-api-version' into 'master'
sms-filter: Add api_version field

See merge request !159
2017-12-08 12:37:05 +00:00
Slava Monich
2186c60630 [ril] Handle SIM reset. Fixes JB#40010
This happens when we receive a proactive Refresh command from SIM Tookit
which is generated by some SIMs when people are moving between home and
roaming networks.
2017-12-08 15:26:44 +03:00
Slava Monich
d5fb195e2f [ofono] sms-filter: Added api_version field. JB#37478
This makes it possible to keep using old plugins even if
struct ofono_sms_filter gets extended with new callbacks.
2017-12-08 15:22:16 +03:00
Slava Monich
cbb08079d2 [ril] Housekeeping
Removed some unused stuff
2017-12-07 17:23:22 +03:00
Slava Monich
0583a831fb Merge branch 'sfos_bt_crash' into 'master'
Handle multiple EMULATOR_HFP atoms

See merge request !158
2017-12-01 15:02:32 +00:00
Slava Monich
a8a0758e90 [sailfish_bt] Handle multiple EMULATOR_HFP atoms. Fixes JB#40530
It appears that in some rare cases a new (second) instance can be
created before the old one is destroyed. This was causing a crash.
2017-12-01 16:44:57 +02:00
Slava Monich
9e267487f4 Merge branch 'devel' into 'master'
Add more stuff to ofono devel package

See merge request !157
2017-11-27 20:15:16 +00:00
Slava Monich
c8a774dfee [ofono] Add gdbus.h to the devel package. JB#37478
External (dynamically loadable) plugins need it.
2017-11-27 21:53:25 +02:00
Slava Monich
b88518d0f3 [ofono] Adapt Sailfish OS plugins to newly introduced <ofono/storage.h> 2017-11-27 21:53:25 +02:00
Slava Monich
b223ccc675 storage: Implement ofono_config_dir and ofono_storage_dir 2017-11-27 21:53:25 +02:00
Slava Monich
947a41a5fc include: Add storage.h
To expose ofono directories to dynamically loadable plugins.

Conflicts:
	ofono/Makefile.am
2017-11-27 21:53:25 +02:00
Slava Monich
e0b4e8694d [ril] Fixed a few compilation warnings 2017-11-14 12:47:49 +02:00
Slava Monich
c8db770c99 [ril] Don't retry REQUEST_GET_CURRENT_CALLS on RADIO_NOT_AVAILABLE
Assume that in this case there's no active voice calls.
2017-11-14 12:41:08 +02:00
Slava Monich
1534143e31 [ril] Don't retry REQUEST_DATA_CALL_LIST on RADIO_NOT_AVAILABLE
Assume that in this case there's no active calls.
2017-11-14 12:38:49 +02:00
Slava Monich
d9ad9caf30 Merge branch 'get_imei' into 'master'
Add legacyImeiQuery configuration option.

See merge request !155
2017-11-14 10:33:56 +00:00
Slava Monich
71de574e87 [ril] Added legacyImeiQuery configuration option. JB#39612
MTK ril doesn't understand RIL_REQUEST_DEVICE_IDENTITY
2017-11-13 22:28:31 +02:00
Slava Monich
11efbd68e6 Bumped spec version to 1.20 2017-11-08 20:48:38 +03:00
Slava Monich
9981f07797 Merge branch 'v1.20' into 'master'
[ofono] Upgrade baseline to 1.20. Fixes JB#40330

See merge request !153
2017-11-08 17:47:17 +00:00
Marcel Holtmann
24733f776e Release 1.20 2017-11-08 18:20:52 +03:00
Alexander Couzens
50ec234239 plugins/gobi: add the qmi type to the debug output of discover_cb() 2017-11-08 18:20:52 +03:00
Alexander Couzens
b4991076c6 udevng/gobi: allow to detect ec20 tty devices
The Quectel EC20 uses the same usb id as some gobi 2000 modules (05c6:9215).
2017-11-08 18:20:52 +03:00
Alexander Couzens
8b02884696 udevng/gobi: use subsystem as first identification
Using kernel 4.10 with systemd 232 on archlinux the detection of
a gobi 2000 doesn't detect the qmi/cdc-wdm interface.

The device is detected as follows:

[devnode interface number label sysattr subsystem]
/dev/cdc-wdm1 255/255/255 00 (null) (null) usbmisc
wwan1 255/255/255 00 (null) (null) net
/dev/ttyUSB5 255/255/255 01 (null) (null) tty
/dev/ttyUSB6 255/255/255 02 (null) (null) tty
/dev/ttyUSB7 255/255/255 03 (null) (null) tty
2017-11-08 18:20:52 +03:00
Alexander Couzens
8e224a21f6 udevng/gobi: improve debug output
Add info->sysattr and info->subsystem to the log message.
2017-11-08 18:20:52 +03:00
Luiz Augusto von Dentz
96e191b2d2 handsfree-audio: Add Acquire implementation
This adds Acquire method which can be used by agents that require
pulling the fd directly instead of waiting a NewConnection.
2017-11-08 18:20:52 +03:00
Luiz Augusto von Dentz
7ae3aad622 doc/handsfree-audio-api: Add Acquire method
This adds Acquire method which can be used by agents that require
pulling the fd directly instead of waiting a NewConnection.

Note: sounds servers like PulseAudio do auto suspend streams when idle
for a certain amount of time and once anything happens it will resume
the stream, though this all happens in the so called IO thread in a
blocking fashion making it impossible to receive the fd via NewConnetion
causing the stream to fail to resume. There are other forms to work
around but this seems to be most convenient as we do want the auto
suspend feature to work properly but letting the stream to fail to
resume may create unexpected artifacts while the NewConnection is
handled in main thread.
2017-11-08 18:20:52 +03:00
Luiz Augusto von Dentz
3d5d88241e hfp_hf_bluez5: Rework code handling device changes
This splits the handling of device changes and modem registration so
they can be uses separately.
2017-11-08 18:20:52 +03:00
Jonas Bonn
31e62567e6 qmimodem: set APN for LTE default bearer
Apparently, an empty APN in an ofono context means that that the context
cannot be activated.  connman definitely interprets it this way.

This patch sets a default name of "automatic" for the default bearer if
no other LTE APN is supplied (which is currently the case as the LTE
atom is not in place yet).  Without this, connman happily ignores the
context, even though it has been activated by ofono.
2017-11-08 18:20:52 +03:00
Jonas Bonn
8c3127ef21 qmi: activate default bearer context for LTE networks
When the modem attaches to an LTE network, a default bearer is
automatically negotiated using the "defalt profile" settings.  The
QMI modem, however, does not given any explicit indication that
the bearer exists; instead, we must assume its existence based on
the network registration state.

This patch extends the GPRS atom to signal the presence of a
default bearer when it detects network connectivity on an LTE
network.
2017-11-08 18:20:51 +03:00
Jonas Bonn
1c1fc4199e qmi: use named status values 2017-11-08 18:20:51 +03:00
Jonas Bonn
bfe2f95c4c qmi: use shared services
Apparently it's not legal to create a QMI service multiple times for
a device.  I've been testing with a Quectel EC21 and here it works fine
to do so, but the general case would require "shared" services across
atoms.

This patch switches the users of the NAS and WDS services over to using
a "shared" service instead of each instatiating their own instance.
2017-11-08 18:20:51 +03:00
Jonas Bonn
7e4d99236b qmi: watch packet status for spontaneous disconnection only
There are three principal ways for a context to become disconnected:

i)  deactivate_primary() is called
ii)  the network registration is lost and the context is cleaned up
via _detach_shutdown() (via release_all_contexts())
iii) the network decides to disconnect the context

We need to watch the packet status in order to detect case iii).  For
case i) and ii), stop_net will be called, the pkt_handle will be
cleared, and subsequent packet status notifications be ignored.

This patch makes it so that the packet status "disconnected" event
is only propagated when the pkt_handle has not been cleared, indicating
an unrequested disconnection.

This should fix a race reported by Christophe Ronco whereby the packet
status disconnect notification is called between activate_primary
(start_net) and it's callback (start_net_cb).
2017-11-08 18:20:51 +03:00
Luiz Augusto von Dentz
0935a227be hfp_hf: Handle ServicesResolved signal
This adds handling for ServicesResolved signal which tells when BlueZ
is done resolving the device services so the code will no longer ignore
devices that got its services resolved after Paired signal.
2017-11-08 18:20:51 +03:00
Luiz Augusto von Dentz
ffdeb3692c hfp_hf: Fix not creating modem during NewConnection
In case the UUIDs are not updated, as they are still being resolved, when
Paired property changes a modem will never be registered.

In order to fix this problem allow modems to be registered directly
during NewConnection.
2017-11-08 18:20:51 +03:00
Vincent Cesson
627904e382 gemalto: Set vendor for sms atom 2017-11-08 18:20:51 +03:00
Vincent Cesson
0ab0677765 atmodem: Fix SMS reception for Gemalto modems
SMS reception is not working for Gemalto modems because of +CMT parsing.
PDU length is the first argument of +CMT URCs in Gemalto modems.

Add a switch case on vendor info to handle Gemalto case.
Also handle acknowledgment, +CNMA takes only one parameter.

CMT parsing is moved from at_parse_cmt() to at_cmt_notify(). This
function is modified to match the style of at_cmgr_notify() and it
includes a switch case for CINTERION modems.
2017-11-08 18:20:51 +03:00
Jonas Bonn
fe6af108ca Add support for Quectel EC21/25 modems
This follows the same pattern as the Telit QMI modems, routing the
setup through a QMI driver.  I think this can be cleaned up somehow,
but for now this at least provides support for these two modem models
so that others can aid in testing.
2017-11-08 18:20:51 +03:00
Vincent Cesson
650ff3642f gemalto: Use sim_state_query for sim detection
Populate gemalto_data structure.
Add sim_state callbacks.
Fix enable/disable return value.
2017-11-08 18:20:51 +03:00
Jonas Bonn
41d310aa61 qmi: move rat_to_tech() into own module
We want to use this function from multiple atoms so this patch moves
it out to its own module for NAS-related helper functions.
2017-11-08 18:20:51 +03:00
Jonas Bonn
27adf83a4b ofono: add missing header inclusions
This is a "leaf" header and doesn't even have header guards, but
it still seems natural that the header should pull in its own declarations
rather than relying on the including source file to ensure that they
are included.
2017-11-08 18:20:51 +03:00
Jonas Bonn
55d227ba46 qmi: add missing header inclusion 2017-11-08 18:20:51 +03:00
Jonas Bonn
dcc1d366f0 qim: use named status value 2017-11-08 18:20:51 +03:00
Jonas Bonn
83cf94824d qmi: implement detach_shutdown method
The detach_shutdown method is invoked to unconditionally release
an active context.  For QMI, this is equivalent to a call to
deactivate_primary.

This patch makes the callback to deactivate_primary optional and
implements detach_shutdown to simply call it.  When there is no
callback, the stop_net callback notifies ofono about the context
release via an asynchronous ofono_gprs_context_deactivated() call.
2017-11-08 18:20:51 +03:00
Jonas Bonn
3a0c598805 qmi: free cb_data on error
...and move allocation of structure up to variable declarations to
match the pattern used elsewhere in the code.
2017-11-08 18:20:51 +03:00
Jonas Bonn
b098314251 qmi: read_settings needs to call start network
For LTE networks, a default bearer is automatically activated when
the modem registers to the network.  QMI modems, however, do not
automatically enable the network interface just because the bearer
exists; a call to "start network" needs to be made in order to
get the packet handle before get_settings will return any data and
the network interface can be configured.

This patch makes read_settings call "start network" in order to
enable the interface for the default bearer.  No new bearer will
be created with this call and the settings for the bearer will come
from the default profile, irregardless of what parameters are passed
to the "start network" method.
2017-11-08 18:20:51 +03:00
Jonas Bonn
4ae6c6c0b1 gprs: set driver_attached when activating automatic contexts
The ofono_gprs_cid_activated attachment machinery cannot go through
ofono_gprs_status_notify for getting the attached property set because
that would result in the automatic contexts that were just set up
being released.  As such, it needs to call gprs_set_attached_property
manually.  Doing so, however, means that the driver_attached property
never gets set, resulting in all contexts being released when the
network transitions between registered states (roaming/non-roaming).
2017-11-08 18:20:51 +03:00
Jonas Bonn
d5f0f3b32d gprs: _cid_activated is an 'attaching' state
ofono_gprs_status_notify is an asynchronous notification that messes
with the 'attached' state of the GPRS atom.  This method is normally
prevented from running while an attach is in progress because the
attachment machinery wants to finish up and make it's own determination
of attach state.

When automatic context activation is relevant, as for LTE networks,
the ofono_gprs_cid_activated machinery replaces the usual set_attach
machinery for attaching to the network.  The cid_activated variant,
however, does not guard against simulatenous invocations of
ofono_gprs_status_notify.  This causes a race whereby status_notify
sets the state to 'attached' before the context is fully constructed
and set to active.  If the connection manager sees the 'attached'
state before there are any 'active' contexts, it may decide to
activate a context manually which is not the correct behaviour for
this type of network.

This patch makes the *_cid_activated machinery an 'attaching' state,
introducing the same guards that set_attached has to prevent
ofono_gprs_status_notify from running concurrently.
2017-11-08 18:20:51 +03:00
Jonas Bonn
0209e9847b qmi: fix typo 2017-11-08 18:20:51 +03:00
Jonas Bonn
a499ac07ca qmi: duplicate callback data correctly 2017-11-08 18:20:51 +03:00
Vincent Cesson
04342bbe69 gemalto: Change offline mode, keep USIM available
Gemalto has two airplane mode:
CFUN=0 disables USIM
CFUN=4 keeps USIM connected
2017-11-08 18:20:51 +03:00
Vincent Cesson
d0d3e4f2f1 gemalto: Clean post init functions
Remove inappropriate interfaces.
Move GPRS init from post_online to post_sim.
2017-11-08 18:20:51 +03:00
Denis Kenzior
edcbc5c7e3 AUTHORS: Mention Jonas' contributions 2017-11-08 18:20:51 +03:00
Denis Kenzior
1df55e3042 qmi: Use destroy callback for context activate 2017-11-08 18:20:51 +03:00
Denis Kenzior
df93fceb4f qmi: Use destroy callback for context deactivate
This ensures that cbd will be freed even if the device is hot-unplugged.
Also, this fixes a memory leak on the failure path inside stop_net_cb
2017-11-08 18:20:51 +03:00
Jonas Bonn
d21d1a166f qmi: implement read_settings for automatic contexts
For LTE, a context is created automatically when the modem registers
to the network.  The read_settings function is called for these
automatic contexts to get their configuration.
2017-11-08 18:20:51 +03:00
Jonas Bonn
458f905262 qmi: retrieve GPRS context parameters
The GPRS context needs to be configured with connection parameters when
the bearer has been established.  This was only partially implemented, so
this patch adds additional parameters to those passed to the context.
2017-11-08 18:20:51 +03:00
Jonas Bonn
9f474ba723 qmi: add WDS parameter definition 2017-11-08 18:20:51 +03:00
Jonas Bonn
a3b4421422 qmi: NAS definitions adjustment
Calling the ps_state/cs_state alternatives *ATTACH_STATUS* was confusing
because there is also a status field in the *serving_system structure.
This patch does a minor rename and adds the appropriate definitions for
the status field.
2017-11-08 18:20:50 +03:00
Denis Kenzior
28bc1e37ed qmi: Fix qmi_device_shutdown
qmi_device_shutdown allocated a new orphaned data structure and kicked
off a timeout to wait for the shutdown to complete.  The logic was quite
racy, but the main issue was that the timeouts could not be canceled
when the underlying qmi_device object was destroyed.  This resulted in
crashes.

This patch switches to first-past-the-gate mechanism.  Since only the
modem driver should be issuing a qmi_device_shutdown call, this should
not be a limitation.  The shutdown source is then tracked on the
qmi_device object itself and is canceled when the qmi_device object is
freed.

As an added bonus, the shutdown_destroy callback should now actually
function.  Before it was simply never called.
2017-11-08 18:20:50 +03:00
Denis Kenzior
c0b96a4319 qmi: Optimize structure allocations
struct discovery was allocated for every discovery procedure that was
kicked off, which itself allocated a structure.  This patch uses a
class/subclass concept to only allocate a single structure per discovery
procedure.
2017-11-08 18:20:50 +03:00
Jonas Bonn
4296616d00 modem: set_online is valid for AlwaysOnline modems
Calling set_online(TRUE) for an AlwaysOnline modem should succeed; the
modem is, after all, in the requested state when the call returns.
Returning not_implemented is not necessarily wrong, but it's a bit ugly.
2017-11-08 18:20:50 +03:00
Jonas Bonn
3a43f96fe4 qmi: fix bad lookup and double free
This function was never removing discovery instances because it was looking
them up in the wrong list.  This led to some strangeness with the discovery
callbacks being invoked after the "failure" timeout of 5 seconds and
consequent failures with everything getting out of sync.

With this patch we fix the lookup to use the correct queue.  There's also
a double-free in the function that was never being hit before because the
lookups never succeeded; fix that as well.

With this, service discovery and creation work as expected when testing with
an EC21.
2017-11-08 18:20:50 +03:00
Jonas Bonn
b82a1001e2 qmi: add service ID's 2017-11-08 18:20:50 +03:00
Jonas Bonn
84dc7e2016 udevng: remove 'option' driver setup
No driver named 'option' exists so this device can never be instantiated.
2017-11-08 18:20:50 +03:00
Lukasz Nowak
1482728a61 atmodem: telit - re-attach gprs automatically
Telit AT modem firmware (tested with UE910-EUR) generates
+CGREG: 0\r\n\r\n+CGEV: NW DETACH
after a context is de-activated and ppp connection closed.
Then, after a random amount of time (observed from a few seconds
to a few hours), an unsolicited +CGREG: 1 arrives.
Attempt to fix the problem, by sending AT+CGATT=1 once.
This does not re-activate the context, but if a network connection
is still correct, will generate an immediate +CGREG: 1.
2017-11-08 18:20:50 +03:00
Jonas Bonn
428f62041b plugins: remove udev module
This functionality has been moved into the udevng module and was
already disabled in an earlier patch.
2017-11-08 18:20:50 +03:00
Jonas Bonn
4b6ec99973 udevng: get properties from interface
Device properties are generally on the device, on the USB interface
descriptor, or the on the USB device descriptor.
2017-11-08 18:20:50 +03:00
Jonas Bonn
0c01da5378 udevng: hook up legacy devices
...and disable old udev code by shorting it out in it's init() function.

The check_device function is augmented to differentiate between USB
and serial devices:

- if the device sits on a USB bus, the device is handled as before
- if not, an attempt is made to handle the device as a serial device
2017-11-08 18:20:50 +03:00
Jonas Bonn
8004756c3d udevng: match on the hsi subsystem for legacy devices 2017-11-08 18:20:50 +03:00
Jonas Bonn
e01df1a3f1 udevng: add serial device handling functions
This adds, but does not hook up, support for simple serial modems.  These
modems generally have only a single device node so are simpler than the
USB devices which generally have different device nodes for different
functions.  These modems are currently handled by udev.c, but this
functionality will allow to remove that module completely in a later patch.

- A new "device_info" type is created called serial_device_info
- the function add_serial_device sets up a modem_info structure and a
  serial_device_info for the device
- A reference to the device's udev node is saved in the device info
- The device driver is retrieved from the OFONO_DRIVER environment variable
  which needs to be set up by some udev rule
- Setup functions are added for these types of devices: a common function
  setup_serial_modem covers the generic (simple) case, whereas modems
  with special requirements are given their own setup functions to handle
  the special bits
- Modem destroy needs to know the "device_info" type in order to clean
  up properly, so a 'type' value is set on the modem_info structure to
  guide selection of the proper cleanup function
2017-11-08 18:20:50 +03:00
Denis Kenzior
46820a7ba0 qmi: track discovery tasks so clean up is possible
There are various device & service discovery tasks that are initiated
based on a qmi_device object.  qmi_device object does not currently
keep track of these tasks.  Unfortunately the qmi_device object can
go away at any time, and these tasks can become orphaned.

The result of this can lead to crashes.  E.g. a discovery task timeout fires
after the qmi_device object has been destroyed.  Since the object is no
longer valid, any accesses to it will likely result in a SEGFAULT.

This patch attempts to track all discovery tasks on the qmi_device
object itself, so that they can be cleaned up properly.  This patch does
not handle the qmi_device_shutdown functionality.
2017-11-08 18:20:50 +03:00
Lukasz Nowak
0493629a9d unit: rilmodem-test - add missing string.h
Remove warnings of undeclared memcpy, strncpy, etc.
2017-11-08 18:20:50 +03:00
Lukasz Nowak
41b3459a5d udevng: add Telit LE910 V1 support
Tested with LE910-SVG and Verizon.
2017-11-08 18:20:50 +03:00
Jonas Bonn
b27373c8a4 udev: remove extraneous subsystem check
The enumeration construct is already set up with matches for these
subsystems.
2017-11-08 18:20:50 +03:00
Jonas Bonn
b450c8fbe3 udev: simplify wavecom modem registration 2017-11-08 18:20:50 +03:00
Jonas Bonn
1ac24f32e3 udev: simplify ifx modem registration 2017-11-08 18:20:50 +03:00
Jonas Bonn
977fc5bc15 udev: add common modem registration code
Many of these drivers do exactly the same setup when registering
the modem.  Consolidate these setup functions into common code.
2017-11-08 18:20:50 +03:00
Jonas Bonn
787bddf47b udev: simplify add_modem
Adding a modem boils down to finding the device in the hierarchy with
the OFONO_DRIVER property.  The original code special-cased the property
being on the device itself rather than on a parent device.  This patch
combines the two cases.
2017-11-08 18:20:50 +03:00
Jonas Bonn
c32cd532f2 udev: remove unused modem property
The property 'Registered' is not used anywhere.
2017-11-08 18:20:50 +03:00
Jonas Bonn
18f2345124 udev: get udev property via lib function 2017-11-08 18:20:50 +03:00
Jonas Bonn
00b623e8c4 udev: remove extraneous subsystem check
The udev-monitor already guarantees that only devices with these
subsystems will be returned so we don't need to check again.
2017-11-08 18:20:50 +03:00
Jonas Bonn
452108d058 ofono.rules: remove 'change' action
The code doesn't do anything with this action so don't bother setting
extra device properties for it.
2017-11-08 18:20:50 +03:00
Jonas Bonn
6b0712dae4 udevng: simplify logic in check_usb_device
This patch simplifies and cleans up the check_usb_device function a bit
by doing the two following (slightly intertwined) things:

1)  The parent "usb_device" is searched for early in this function and this
device will always have the ID_VENDOR_ID and ID_MODEL_ID properties.
As such, we can get them from this device and thereby be certain that
we _always_ have them available.

2)  The logic of iterating the vendor_list table is cleaned up.  It's
easier to follow and won't be any less efficient.
2017-11-08 18:20:50 +03:00
Jonas Bonn
9a309f499b gobi: query presence of WDA service 2017-11-08 18:20:50 +03:00
Jonas Bonn
a204c993e5 qmimodem: add WDA service string 2017-11-08 18:20:50 +03:00
Jonas Bonn
e881376127 qmimodem: fix typo 2017-11-08 18:20:50 +03:00
Lukasz Nowak
66c98d724c gobi: Do not use low-power modes for some modems
Telit QMI modems have a problem with the low-power operating modes.
After entering and leaving such a state, UIM service does not return.
The sim card is still marked as powered-down. The QMI interface does
not have a way to power it back on.

To avoid this, keep modems with the "AlwaysOnline" flag online
in the disable-modem and offline-modem procedures.
2017-11-08 18:20:49 +03:00
Denis Kenzior
5c38fe6a84 AUTHORS: Mention Lukasz's contributions 2017-11-08 18:20:49 +03:00
Lukasz Nowak
e3bb317504 qmimodem: detect utf-8 string as operator name
Telit QMI modems can return non-utf-8 characters in plmn-desc.
Observed with LE910-SVG and Verizon. When that happens, libdbus
will abort ofono.
If non-utf-8 characters are detected, use mccmnc string.
2017-11-08 18:20:49 +03:00
Lukasz Nowak
713022a7e8 qmimodem: read ss_info at probe time
LTE modems (observed with Telit LE910 V1) can power on
already registered to a network. In that case, the SS_INFO
change notification will never arrive, and the gprs driver
will never be marked as attached.

To avoid this situation, read SS_INFO at probe time, and if
registered, mark the gprs driver as attached.
2017-11-08 18:20:49 +03:00
Denis Kenzior
6b79f32715 qmimodem: Fix warning
This was introduced by the previous patch:
drivers/qmimodem/devinfo.c: In function ‘get_ids_cb’:
drivers/qmimodem/devinfo.c:129:14: error: implicit declaration of function ‘strcmp’ [-Werror=implicit-function-declaration]
  if (!str || strcmp(str, "0") == 0) {
2017-11-08 18:20:49 +03:00
Lukasz Nowak
2386e99ad8 qmimodem: telit LE910 V1 - fix ESN string
Telit QMI modems report "0", rather than a NULL string,
if ESN is not available.
2017-11-08 18:20:49 +03:00
Christophe Ronco
6ca82960c9 huawei: reopen modem channel if it disconnects
On E3372 after a GPRS disconnection, modem AT channel (used by PPP) gets
disconnected (G_IO_HUP and G_IO_ERR are detected in received_data
in gatio.c).
After that all connection attempts fail because we are not able to send
any AT commands on modem channel (it is closed).

With this patch, when this behavior is detected, we close gprs context
driver, reopen AT channel and gprs context driver.
2017-11-08 18:20:49 +03:00
Christophe Ronco
93891578fc provision: add plugin to provision from config file
This plugin allows to provision gprs-context data based on MCC and MNC.
This is useful when provisioning using mbpi fails (either because you
are using a private APN or because there are multiple internet type context
for your operator in mbpi database).
Config file is STORAGEDIR/provisioning.
Config file should look like that:
[operator:MCC1,MNC1]
internet.AccessPointName=apn1
internet.Username=myUsername
internet.Password=myPassword
internet.AuthenticationMethod=pap
internet.Protocol=ipv6
[operator:MCC2,MNC2]
internet.AccessPointName=apn2

The only mandatory parameter for each operator is internet.AccessPointName.

Parameter description:
internet.AccessPointName: APN
internet.Username: Username
internet.Password: Password
internet.AuthenticationMethod: authentication method.
 Possible values are:
  - pap
  - chap
 Default is chap if unset.
internet.Protocol: protocol
 Possible values are:
  - ip: ipv4
  - ipv6
  - dual
 Default is ip if not set.

All parameters are prefixed with internet to be able to extend this plugin
to other type of contexts (MMS, ...).

Conflicts:
	ofono/Makefile.am
	ofono/plugins/file-provision.c
2017-11-08 18:20:49 +03:00
Christophe Ronco
7bcadcd300 qmimodem: fix sim file reading on MC7304
Command read_file_info on MC7304 always fails.
Using qmicli or AT command, I am able to read file info.
Qmicli command is:
qmicli -d /dev/cdc-wdm0 --uim-get-file-attributes=0x3f00,0x7fff,0x6fad
[(null)] Successfully got file '/dev/cdc-wdm0' attributes from the UIM:
Card result:
        SW1: '0x90'
        SW2: '0x00'
File attributes:
        File size: 4
        File ID: 28589
        File type: transparent
        Record size: 0
        Record count: 0
        Read security attributes: (always) (null)
        Write security attributes: (single) adm
        Increase security attributes: (always) (null)
        Deactivate security attributes: (single) adm
        Activate security attributes: (single) adm
        Raw:    62:17:82:02:41:21:83:02:6F:AD:8A:01:05:8B:...

After a check of parameters sent by qmimodem driver and qmicli,
the only difference is on parameter "Session Information".
Session type sent by qmimodem driver is 'Card on slot 1'.
Session type sent by qmicli command is 'primary-gw-provisioning'.
Changing session type in qmimodem driver fixed problem (on this modem).

Comparing with what is done by qmili command
2017-11-08 18:20:49 +03:00
Christophe Ronco
b3f8dc4a24 atmodem: use ATD99 to enter data state when needed
Some modems do not support AT+CGDATA="PPP",X to enter data state.
Use AT+CGDATA=? to detect these modems and for them use ATD*99***X#
to enter data state.
2017-11-08 18:20:49 +03:00
Christophe Ronco
38e3122217 gprs: fix error check of gprs_cid_alloc function
When there is no context id available, idmap_alloc and
gprs_cid_alloc return max + 1.
2017-11-08 18:20:49 +03:00
Piotr Haber
f7de0ab3ef telit: register SIM if it goes straight to ready
SIM without PIN goes straight to state 3 (INSERTED and READY)
on some modem/firmware versions.
2017-11-08 18:20:49 +03:00
Denis Kenzior
defe008062 rilmodem: Fix warning
drivers/rilmodem/stk.c: In function ‘ril_stk_probe’:
drivers/rilmodem/stk.c:210:18: error: ‘data’ is used uninitialized in
this function [-Werror=uninitialized]
  struct cb_data *cbd = cb_data_new(stk, NULL, data);
2017-11-08 18:20:49 +03:00
Denis Kenzior
ec930e17c8 AUTHORS: mention André's contributions 2017-11-08 18:20:49 +03:00
André Draszik
9f1731cffa plugins: telit: send AT&C0 on both channels
At least firmware version 12.00.405 on the UE910-EUR otherwise
closes the AT command port whenever the PPP connection is
dropped, and we'd be left in a funny state.
2017-11-08 18:20:49 +03:00
Antara Borwankar
ed8d55d2d5 ril_intel: Add support for stk 2017-11-08 18:20:49 +03:00
Antara Borwankar
7b6a461b83 rilmodem: Send needed RIL request for stk init
sending RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING after
stk atom is created so that modem will inititialize
sim toolkit by sending terminal profile to sim.
2017-11-08 18:20:49 +03:00
Piotr Haber
3b0ff8fd83 telit: add support for UE866 2017-11-08 18:20:49 +03:00
Piotr Haber
00b5886cf9 udevng: unify telit and xe910
Unified setup for Telit devices using
usbserial and cdc_acm drivers.
2017-11-08 18:20:49 +03:00
Piotr Haber
c16fd4e642 plugins: rename xe910 to telit
Unify old telit and xe910 plugins.
Dropping support for Bluetooth SAP.
Add support for UC864 family.
2017-11-08 18:20:49 +03:00
Christophe Ronco
4b92ac8ba6 qmimodem: change kernel driver data format if needed
During gprs-context driver probe function, check kernel device driver
data format and modem low level data format.
If they are different, align kernel device driver data format on
modem low level data format.
If an error occurs during this process, continue probing without error.
This is inspired by what is done in qmicli and qmi-network (package
libqmi).
2017-11-08 18:20:49 +03:00
Denis Kenzior
5b432b8280 qmi: Fix typo 2017-11-08 18:20:49 +03:00
Christophe Ronco
31aff54463 qmimodem: get/set kernel device driver data format
Add a way to get and set data format expected by kernel device driver.
This is inspired by what is done in qmicli (package libqmi).
It does not use QMI protocol but a sysfs exported by kernel driver.
To use this feature, kernel version must be equal or more than 4.5.
2017-11-08 18:20:49 +03:00
Denis Kenzior
c669ec3c88 tools: Remove unused qmi tool 2017-11-08 18:20:49 +03:00
Piotr Haber
8c2f54abe0 xe910: support for Telit LE910V2 modem
LE910V2 is next generation Telit LTE modem.
It supports 3GPP Rel. 9 LTE Cat. 4 over multiple bands.
2017-11-08 18:20:49 +03:00
Piotr Haber
804121cbed telitmodem: support for CDC-NCM network adapter
Network Control Model is a new Communication Device Class
protocol for exchanging Ethernet frames over USB.
NCM is intended to be used with high-speed network
attachments such as HSDPA and LTE data services.
2017-11-08 18:20:49 +03:00
Piotr Haber
839e626ee6 udevng: setup of Telit LE910V2
Setup LE910V2 in default USB composition (1bc7:0036)
with 6 CDC-ACM serial ports and 1 CDC-NCM network adapter.
2017-11-08 18:20:49 +03:00
Piotr Haber
3a17724136 plugins: Handle HE910 and UE910 variants
Telit modems HE910 and UE910 share the same USB
vendor and device IDs (1bc7:0021) but they are
different devices.
HE910 is HSPA Class 14/6 and UE910 is Class 8/6.
Both come in voice-enabled variants.
HE910 also comes in variants with built-in GPS.
2017-11-08 18:20:49 +03:00
Piotr Haber
7b0c6610e0 plugins: rename he910 to xe910
In preparation for more generic support
of Telit xE910 family.
2017-11-08 18:20:49 +03:00
Piotr Haber
0e0b1e98c5 qmimodem: send authentication credentials
Pass authentication method, user and password
to QMI WDS service.
2017-11-08 18:20:48 +03:00
Piotr Haber
b0975c44b1 doc: description of Telit LE910V2 network setup
NCM network interface on LE910V2 modem needs to be
configured in a specific way after connection is established.
2017-11-08 18:20:48 +03:00
Denis Kenzior
25a6049cf6 doc: Add 'switch' to item M1 2017-11-08 18:20:48 +03:00
Denis Kenzior
02fcbdb245 AUTHORS: Mention Piotr's contributions 2017-11-08 18:20:48 +03:00
Piotr Haber
a3a8ea4183 atmodem: add LTE to Telit #PSNT status parser
Network type of 4 in Telit #PSNT command response
denotes LTE network
2017-11-08 18:20:48 +03:00
Vincent Cesson
92d7fb848b gemalto: Add location reporting support 2017-11-08 18:20:48 +03:00
Vincent Cesson
0b6327a7fc drivers: Add gemaltomodem driver to handle GNSS
Add a new location-reporting driver for Gemalto Cinterion modems based
on telit implementation + use it in gemalto plugin. It supports
activation of GNSS engine (Request) with command AT^SGPSC. This driver
is tested on PHS8. NMEA frames are accessible on /dev/ttyUSB1.
2017-11-08 18:20:48 +03:00
Vincent Cesson
84bd588152 udevng: complete gemalto setup
Complete the Gemalto setup with cdc_wdm and qmi,
so all enumerated devices are associated with gemalto.
2017-11-08 18:20:48 +03:00
Christophe Ronco
9e952cf042 qmimodem: query_passwd_state can be retried
Retry command QMI_UIM_GET_CARD_STATUS during query_passwd_state if a
temporary error status has been detected.
This happens with a MC7430 modem when query_passwd_state is called just
after PIN is entered.
2017-11-08 18:20:48 +03:00
Vincent Cesson
27a1a05aa7 udevng: Add Gemalto P-family detection
Add a new function setup, based on telit, to handle Gemalto P-family
discovery. The setup looks for USB interfaces:
application=/dev/ttyUSB2
gps=/dev/ttyUSB1
modem=/dev/ttyUSB3
2017-11-08 18:20:48 +03:00
Vincent Cesson
657841e2b0 plugins: Add Gemalto plugin for Cinterion P-family
Actual cinterion plugin is not compliant with newer Gemalto modems.
Gemalto plugin is based on cinterion with a custom struct to handle the
interfaces Application and Modem.
2017-11-08 18:20:48 +03:00
Denis Kenzior
02172f6922 AUTHORS: Mention Vincent's contributions 2017-11-08 18:20:48 +03:00
Vincent Cesson
0dd225b594 atmodem: Fix CGDCONT result parsing.
CGDCONT result parsing fails if first list contains several ranges. For
example with modem Cinterion PHS8:

 AT+CGDCONT=?
 +CGDCONT: (1-17,101-116),"IP",,,(0),(0-4)

Solution: read first range and jump to second list instead of trying to
close the brackets.
2017-11-08 18:20:48 +03:00
Christophe Ronco
452d0d4b5a qmimodem: add pin_send feature
Add ability to send PIN to a QMI modem using QMI_UIM_VERIFY_PIN command.
This has been tested on MC7304 and MC7430 modems.
2017-11-08 18:20:48 +03:00
Christophe Ronco
2edae61c0b qmimodem: get password state from modem
Password state and number of retries asked to modem using
QMI_UIM_GET_CARD_STATUS command rather than remembered after initial
QMI_UIM_GET_CARD_STATUS command.
2017-11-08 18:20:48 +03:00
Christophe Ronco
141abd5390 udevng: Sierra modems use SIM driver 2017-11-08 18:20:48 +03:00
Christophe Ronco
22faa0f26a qmimodem: Add read_imsi to qmimodem sim driver
Add read_imsi feature to qmimodem sim driver.
This is based on DMS service.
On MC7430, this is mandatory to be able to use this driver for GPRS
connection because reading IMSI via EF reads fails.
2017-11-08 18:20:48 +03:00
Christophe Ronco
4d2453f3a8 sim: backup driver read_imsi by IMSI via EF read
If read_imsi driver function fails, try to obtain IMSI via EF read
2017-11-08 18:20:48 +03:00
Slava Monich
7a5f52c1f3 sim: Stop facility lock query sequence on removal
SIM card can be removed while the query is in progress. There's
still a remote possibility that SIM card is removed and inserted
back while the query is pending, that would start the second query
sequence and end up invoking sim_initialize() twice. But at least
these checks reduce the probability of something like that happening.
2017-11-08 18:20:48 +03:00
Christophe Ronco
1ad109f8c7 qmimodem: fix QMI notification messages handling
QMI notification messages handlers are never called on MC7430 without this fix.

- Do not test transaction id before calling notification handler.  On MC7430,
notification messages contain a not null transaction id (starts with 1,
increased at each message for a particular client).
- On MC7304 transaction id in notification messages is always 0.
2017-11-08 18:20:48 +03:00
Denis Kenzior
1347755b6f AUTHORS: Mention Christophe's contributions 2017-11-08 18:20:48 +03:00
Christophe Ronco
62253744a7 qmimodem: fix get signal strength
Get current signal strength (type: 0x01), not list of other signals strength
(0x10)

Without this fix:
- I can't get a signal strength on MC7430 because list does not exist
	(only one signal strength).
- On MC7304, result is wrong
2017-11-08 18:20:48 +03:00
Marko Šulejić
9a608210cd atmodem: fix typo 2017-11-08 18:20:48 +03:00
Djalal Harouni
adbfdb23a7 test:netmon: support EARFCN, Eband and CQI in testing scripts 2017-11-08 18:20:48 +03:00
Djalal Harouni
ac5d0abe5e netmon: handle OFONO_NETMON_INFO_{EARFCN|EBAND|CQI} 2017-11-08 18:20:48 +03:00
Djalal Harouni
8dbaaa5efe doc: document netmon EARFCN, EBand and CQI properties
Documentation for:
EARFCN: E-UTRA Absolute Radio Frequency Channel Number.
EBand: E-UTRA operating Band.
CQI: Channel Quality Indicator.
2017-11-08 18:20:48 +03:00
Djalal Harouni
fa1bcc1c19 netmon: add NETMON_INFO_{EARFCN|EBAND|CQI}
Add the following types to use with ublox modems +UCGED command.

EARFCN: E-UTRA Absolute Radio Frequency Channel Number.
EBand: E-UTRA operating Band.
CQI: Channel Quality Indicator.
2017-11-08 18:20:48 +03:00
Antara Borwankar
32138ecd04 ril_intel: changes for lte modem
plugin modified to bring up lte atom and set MODEM_PROP_LTE_CAPABLE
to TRUE
2017-11-08 18:20:48 +03:00
Antara Borwankar
5e999f0b47 ril_intel: renamed ril_sofia3gr to ril_intel
renamed ril_sofia3gr.c to ril_intel.c
2017-11-08 18:20:47 +03:00
Ankit Navik
5c74095f44 rilmodem: set LTE preferred in rat mode 2017-11-08 18:20:47 +03:00
Ankit Navik
55befb87cd rilmodem: Add lte atom driver
Adds rilmodem driver for setting the default APN command.
The default APN is manage by config storage.
2017-11-08 18:20:47 +03:00
Denis Kenzior
9d7a0f8615 ubloxmodem: Fixup minor style issues
- useless return at the end of a function
- mixed tabs & spaces for indentation
- over 80 characters for the comment
- line > 80 characters due to access technology conversion.  Replaced
  with a direct assignment.
2017-11-08 18:20:47 +03:00
Denis Kenzior
974100732c ubloxmodem: Fix warning
drivers/ubloxmodem/netmon.c: In function ‘req_cb_data_unref’:
drivers/ubloxmodem/netmon.c:131:10: error: ‘return’ with a value, in
function returning void [-Werror]
   return NULL;
2017-11-08 18:20:47 +03:00
Djalal Harouni
35a6a4d8d0 build: build the ublox netmon driver 2017-11-08 18:20:47 +03:00
Djalal Harouni
f2a64c4d15 ubloxmodem: register and initialize the netmon driver 2017-11-08 18:20:47 +03:00
Djalal Harouni
ed1e90990e ubloxmodem: add the netmon driver
This adds a netmon driver for ublox. The driver support both +COPS and
+CESQ commands to return the previously added ofono netmon types:

RSCP: Received Signal Code Power
ECN0: Received Energy Ratio
RSRQ: Reference Signal Received Quality
RSRP: Reference Signal Received Power

Current revision makes the driver use ref countig when chaining multiple
AT commands.
2017-11-08 18:20:47 +03:00
Denis Kenzior
c8a4727243 AUTHORS: Mention Djalal's contributions 2017-11-08 18:20:47 +03:00
Djalal Harouni
2ccabbbdef test: support NETMON_INFO_{RXLEV|RSCP|ECN0|RSRQ|RSRP}
Display the following fields if they are returned.

RXLEV:  Received Signal Strength
RSCP:   Received Signal Code Power
ECN0:   Received Energy Ratio
RSRQ:   Reference Signal Received Quality
RSRP:   Reference Signal Received Power
2017-11-08 18:20:47 +03:00
Djalal Harouni
7c3638143d netmon: handle NETMON_INFO_{RSCP|ECN0|RSRQ|RSRP}
Handle the newly added netmon info types.
2017-11-08 18:20:47 +03:00
Djalal Harouni
a0e8b24c70 doc: Add additional netmon properties
This adds documentation for the following fields in
networkmonitor-api.txt

RSCP: Received Signal Code Power
ECN0: Received Energy Ratio
RSRQ: Reference Signal Received Quality
RSRP: Reference Signal Received Power
2017-11-08 18:20:47 +03:00
Djalal Harouni
41d432211e include: add NETMON_INFO_{RSCP|ECN0|RSRQ|RSRP}
Add more ofono netmon info types that will be served through the netmon
interface. The main user of this now will be the ublox modem.

RSCP: Received Signal Code Power
ECN0: Received Energy Ratio
RSRQ: Reference Signal Received Quality
RSRP: Reference Signal Received Power
2017-11-08 18:20:47 +03:00
Denis Kenzior
94f6138e23 netmon: Fix style issue 2017-11-08 18:20:47 +03:00
Denis Kenzior
e82ce81858 netmon: No need to initialize mcc/mnc 2017-11-08 18:20:47 +03:00
Dragos Tatulea
c18fa5e038 gprs: lte: set attached after successful activation
Otherwise the attached state gets to be set before the actual LTE
automatic context is ready. This triggers a race between connman
and ofono: connman sees status attached before the context is active
so connman will try to activate another context with same apn and will
fail over and over again.
2017-11-08 18:20:47 +03:00
Dragos Tatulea
c7c53adbb5 lte: fix early imsi free
storage_close was creating an empty sync file in /var/lib/ofono/lte
when it should have been closing the proper file
/var/lig/ofono/<imsi>/lte.
2017-11-08 18:20:47 +03:00
Slava Monich
30a9ef7e7a Sync whitespaces with upstream
Conflicts:
	ofono/src/smsutil.c
2017-11-08 18:20:47 +03:00
Dragos Tatulea
064181f903 ubloxmodem: tweak to work on different firmware
The U-Blox documentation specifies the following:
* get interface ip and dns from +CGDCONTRDP
* get gw ip and netmask from +UIPADDR

However, different firmware versions have different befaviour:

* On newer firmware, +UIPADDR returns error. But it's possible to configure
gateway ip == ipterface ip (read from CGDCONTRDP).

* On older firmware, we can actually use the commands specified in the
docs.

This patch runs +CGDCONTRDP, configures everything and then tries to run
+UIPADDR. In that works, reconfigures gw ip and netmask.
2017-11-08 18:20:47 +03:00
Dragos Tatulea
7d22ed86f8 plugins: ublox: enable lte driver for tobyl2 2017-11-08 18:20:47 +03:00
Dragos Tatulea
0641a981d1 build: add support for ublox lte atom driver 2017-11-08 18:20:47 +03:00
Dragos Tatulea
ceb6741a67 ubloxmodem: add lte atom driver
Adds U-Blox Toby L2 driver for setting the default APN via the
+UCGDFLT command. Currently only IPv4 is supported. APN is
not stored to modem's non-volatile memory. oFono will manage this
default APN via it's config storage.

When receiving an empty default APN, the value is reset.
2017-11-08 18:20:47 +03:00
Denis Kenzior
4797cab10b lte: If method is NULL, return not implemented 2017-11-08 18:20:47 +03:00
Denis Kenzior
fbf001bbec lte: Relax condition to g_free imsi
imsi malloc is not directly tied to l_settings being valid
2017-11-08 18:20:47 +03:00
Dragos Tatulea
8e90e96509 build: add lte atom support
Conflicts:
	ofono/Makefile.am
2017-11-08 18:20:47 +03:00
Dragos Tatulea
80e9b97036 lte: add implementation for LTE atom
This implementation can only get/set the default APN setting. But
anything expected for this atom is there:
* D-Bus interface
* sync-ing settings to/from file
* interaction with driver

Conflicts:
	ofono/src/ofono.h
2017-11-08 18:20:47 +03:00
Dragos Tatulea
01103f32ae ubloxmodem: fix memory leak in gprs_context_remove 2017-11-08 18:20:47 +03:00
Denis Kenzior
4bef0c7b33 include: Fix return signature in lte methods
Only the probe method returns a value.  All other methods use a void
return signature and report errors via the callback.
2017-11-08 18:20:47 +03:00
Denis Kenzior
693d5a77bd build: add test/set-lte-property 2017-11-08 18:20:47 +03:00
Denis Kenzior
a2333ead45 build: Add lte-api.txt 2017-11-08 18:20:46 +03:00
Dragos Tatulea
aa6a436af5 doc: add lte atom documentation 2017-11-08 18:20:46 +03:00
Dragos Tatulea
ee350d6b4b test: add script for setting lte atom properties 2017-11-08 18:20:46 +03:00
Denis Kenzior
26b85c0606 include: Make lte method const correct 2017-11-08 18:20:46 +03:00
Dragos Tatulea
068190a7a5 include: add header file for lte atom 2017-11-08 18:20:46 +03:00
Dragos Tatulea
1b292f7cf2 include: add LTE dbus service define 2017-11-08 18:20:46 +03:00
Kuba Pawlak
cd9a19c090 bluez5: fix crash on DBus transport disconnection
Do not register dbus notification if message failed to be sent out
because transport was already disconnected
2017-11-08 18:20:46 +03:00
Kuba Pawlak
6d357e70a4 gatchat: Fix parsing fields with odd number of quotation marks
Events like +CLCC and +CCWA can have contact name attached to the
end of line. If this field contains odd number of quotation marks,
parser will eventually reject such message as malformatted.
2017-11-08 18:20:46 +03:00
Dragos Tatulea
8f4817106d src: add LTE atom define 2017-11-08 18:20:46 +03:00
Slava Monich
d2ce689008 [ofono] Moved ofono_gprs_get_roaming_allowed declaration from gprs.h to ofono.h
.. primarily to make gprs.h identical to upstream. Besides, it's an internal
function, it doesn't have to be defined in gprs.h and exported from ofono in
the first place.
2017-11-08 18:12:15 +03:00
Slava Monich
b470166c87 [ril] Fixed -Wsign-compare compilation warnings
Upstream doesn't have those, let's keep our code clean, too.
2017-11-03 12:12:37 +03:00
Slava Monich
158a0da0b2 sim: Move atom registration to the end of ofono_sim_register
The state needs to be checked prior to calling __ofono_atom_register
because atom registration calls OFONO_ATOM_WATCH_CONDITION_REGISTERED
callbacks each of which may call ofono_sim_inserted_notify. Should
that happen, by the time __ofono_atom_register returns, ofono_sim
will be in OFONO_SIM_STATE_INSERTED state and sim_initialize will
be called twice if the initial state was OFONO_SIM_STATE_NOT_PRESENT.
If nothing else, that results in memory leaks like this one (because
IMSI will be queried twice, among other things):

==3017== 16 bytes in 1 blocks are definitely lost in loss record 187 of 475
==3017==    at 0x483F380: malloc (vg_replace_malloc.c:296)
==3017==    by 0x4AFB0DF: g_malloc (gmem.c:94)
==3017==    by 0x4B12185: g_strdup (gstrfuncs.c:363)
==3017==    by 0xF79D3: sim_imsi_obtained (sim.c:1535)
==3017==    by 0xF7BB3: sim_imsi_cb (sim.c:1594)
==3017==    by 0x66C23: at_cimi_cb (sim.c:441)
==3017==    by 0xA6B53: at_chat_finish_command (gatchat.c:459)
==3017==    by 0xA6D9F: at_chat_handle_command_response (gatchat.c:521)
==3017==    by 0xA70AF: have_line (gatchat.c:600)
==3017==    by 0xA76DF: new_bytes (gatchat.c:759)
==3017==    by 0xABACF: received_data (gatio.c:122)
==3017==    by 0xAD093: watch_dispatch (gatmux.c:461)
==3017==    by 0xAC5D3: dispatch_sources (gatmux.c:180)
==3017==    by 0xAC98F: received_data (gatmux.c:265)
==3017==    by 0x4AF606F: g_main_dispatch (gmain.c:3154)
==3017==    by 0x4AF606F: g_main_context_dispatch (gmain.c:3769)
==3017==    by 0x4AF631D: g_main_context_iterate.isra.4 (gmain.c:3840)
==3017==    by 0x4AF658F: g_main_loop_run (gmain.c:4034)
==3017==    by 0xBE8AF: main (main.c:261)
2017-10-27 19:10:19 +03:00
Slava Monich
b4bbf0462c gatchat: Removed unused GAtPPP field 2017-10-27 01:09:42 +03:00
Slava Monich
d80b96790f atmodem: Query the list of supported <fac>s from the modem
Not all modems support all <fac>s (particularly, "PS"), let's be polite
and not ask them for the ones they don't support.
2017-10-24 02:07:17 +03:00
Slava Monich
accb571fd6 gatmux: Remove write watch source at shutdown
Otherwise write_watcher_destroy_notify can be invoked after
GAtMux has been deallocated which results in write after free:

==3952== Invalid write of size 4
==3952==    at 0xABF54: write_watcher_destroy_notify (gatmux.c:285)
==3952==    by 0x4AF21E7: g_source_callback_unref (gmain.c:1561)
==3952==    by 0x4AF2E53: g_source_destroy_internal.constprop.8 (gmain.c:1207)
==3952==    by 0x4AF61CF: g_main_dispatch (gmain.c:3177)
==3952==    by 0x4AF61CF: g_main_context_dispatch (gmain.c:3769)
==3952==    by 0x4AF658F: g_main_loop_run (gmain.c:4034)
==3952==    by 0xBDDBB: main (main.c:261)
==3952==  Address 0x50c6cb0 is 8 bytes inside a block of size 4,396 free'd
==3952==    at 0x4840B28: free (vg_replace_malloc.c:530)
==3952==    by 0xACB53: g_at_mux_unref (gatmux.c:642)
==3952==  Block was alloc'd at
==3952==    at 0x4841BF0: calloc (vg_replace_malloc.c:711)
==3952==    by 0xAC9DF: g_at_mux_new (gatmux.c:603)
==3952==    by 0xADF2F: g_at_mux_new_gsm0710_basic (gatmux.c:1160)
2017-10-24 02:07:16 +03:00
Slava Monich
523a4b6a81 gatmux: Remove finalized watches from the list
Leaving them there may result in invalid reads like this:

==2312== Invalid read of size 4
==2312==    at 0xAB8C0: dispatch_sources (gatmux.c:134)
==2312==    by 0xAC5D3: channel_close (gatmux.c:479)
==2312==    by 0x4AE8885: g_io_channel_shutdown (giochannel.c:523)
==2312==    by 0x4AE8A1D: g_io_channel_unref (giochannel.c:240)
==2312==    by 0xAC423: watch_finalize (gatmux.c:426)
==2312==    by 0x4AF2CC9: g_source_unref_internal (gmain.c:2048)
==2312==    by 0x4AF44E1: g_source_destroy_internal (gmain.c:1230)
==2312==    by 0x4AF44E1: g_source_destroy (gmain.c:1256)
==2312==    by 0x4AF5257: g_source_remove (gmain.c:2282)
==2312==    by 0xAB5CB: io_shutdown (gatio.c:325)
==2312==    by 0xAB667: g_at_io_unref (gatio.c:345)
==2312==    by 0xA72C7: at_chat_unref (gatchat.c:972)
==2312==    by 0xA829B: g_at_chat_unref (gatchat.c:1446)
==2312==  Address 0x51420f0 is 56 bytes inside a block of size 60 free'd
==2312==    at 0x4840B28: free (vg_replace_malloc.c:530)
==2312==    by 0x4AF2D33: g_source_unref_internal (gmain.c:2075)
==2312==    by 0x4AF44E1: g_source_destroy_internal (gmain.c:1230)
==2312==    by 0x4AF44E1: g_source_destroy (gmain.c:1256)
==2312==    by 0x4AF5257: g_source_remove (gmain.c:2282)
==2312==    by 0xAB46B: g_at_io_set_write_handler (gatio.c:283)
==2312==    by 0xA713F: at_chat_suspend (gatchat.c:938)
==2312==    by 0xA72B7: at_chat_unref (gatchat.c:971)
==2312==    by 0xA829B: g_at_chat_unref (gatchat.c:1446)
==2312==  Block was alloc'd at
==2312==    at 0x4841BF0: calloc (vg_replace_malloc.c:711)
==2312==    by 0x4AFB117: g_malloc0 (gmem.c:124)
==2312==    by 0x4AF401F: g_source_new (gmain.c:892)
==2312==    by 0xAC6A7: channel_create_watch (gatmux.c:506)
==2312==    by 0x4AE7C4F: g_io_add_watch_full (giochannel.c:649)
==2312==    by 0xAB4EB: g_at_io_set_write_handler (gatio.c:297)
==2312==    by 0xA7103: chat_wakeup_writer (gatchat.c:931)
==2312==    by 0xA753F: at_chat_send_common (gatchat.c:1045)
==2312==    by 0xA850F: g_at_chat_send (gatchat.c:1502)

It's also necessary to add additional references to the sources
for the duration of the dispatch_sources loop because any source
can be removed when any callback is invoked (and not necessarily
the one being dispatched).
2017-10-24 00:07:47 +03:00
Slava Monich
9d8a6a4978 Fixed -Wsign-compare warnings
unit/test-sailfish_sim_info.c:86:33: signed and unsigned type in conditional expression
drivers/ril/ril_netmon.c:46:12: comparison between signed and unsigned integer expressions
2017-10-23 23:56:29 +03:00
Slava Monich
f2fa85aa47 [ril] Housekeeping
Took out some leftovers of the past
2017-10-20 18:13:17 +03:00
Slava Monich
a189d13b4a Merge branch 'dbus-queue' into 'master'
Generic queueing of D-Bus requests

See merge request !151
2017-10-19 08:17:38 +00:00
Slava Monich
3b79a77d78 [ofono] radio-settings: Use ofono_dbus_queue for queuing D-Bus requests
Instead of failing with org.ofono.Error.InProgress, requests
are queued and handled in the order they are received.
2017-10-18 23:56:40 +03:00
Slava Monich
c2ee34e51c [ofono] network: Use ofono_dbus_queue for queuing D-Bus requests 2017-10-18 22:39:51 +03:00
Slava Monich
c3bead1c9b [ofono] Generic queueing of D-Bus requests
Instead of failing with org.ofono.Error.InProgress, requests may be queued.
2017-10-18 22:39:21 +03:00
Slava Monich
a26f1a4b5c [ril] Removed a few unused things 2017-10-18 12:43:31 +03:00
Slava Monich
1eacfdf592 [ril] First fix permissions on top-level directories. JB#39961
... and then descend into subdirectories. Even though it doesn't
really matter since we are starting as root, it does seem to be
a bit more logical.
2017-10-13 18:28:42 +03:00
Slava Monich
ba14ed43e4 Merge branch 'perm' into 'master'
Fix storage directory permissions at startup

See merge request !150
2017-10-13 14:33:21 +00:00
Slava Monich
802b3008be [ril] Fix storage directory permissions at startup. Fixes JB#39961
Also, made the identity configurable and got rid of hardcoded radio
uid and gid, those are now queried at runtime.
2017-10-13 17:16:24 +03:00
Slava Monich
3b0191d145 [test] Added test-ril_util 2017-10-13 17:07:26 +03:00
Slava Monich
282d32f70d [ril] Added ril_parse_int utility 2017-10-13 17:05:43 +03:00
Slava Monich
e0c349a18c Merge branch 'smsfilter' into 'master'
SMS filter plugin

See merge request !138
2017-10-10 13:00:08 +00:00
Slava Monich
69d65dc002 [ofono] Support for SMS filter plugins. JB#37478 2017-10-10 15:49:28 +03:00
Slava Monich
33e70ddce4 [ofono] Allow older versions of plugins.
Let's assume that plugin API is going to be backward compatible. If
we start to actually use binary ofono plugins (possibly, 3rd-party),
backward compatibility becomes a must.
2017-10-10 15:49:28 +03:00
Slava Monich
d3ada8fcb3 [ofono] Fixed setting/clearing debug flags for binary plugins
They were added to the list of debug categories but their flags
were not actually getting updated on client's requests.
2017-10-10 15:48:59 +03:00
Slava Monich
4c21ca4e26 atmodem: Fix use after free in sim_state_cb
==2941== Invalid read of size 4
==2941==    at 0x69338: sim_state_cb (sim.c:1301)
==2941==    by 0x71DCB: cpin_check_cb (atutil.c:567)
==2941==    by 0xA602B: at_chat_finish_command (gatchat.c:459)
==2941==    by 0xA6277: at_chat_handle_command_response (gatchat.c:521)
==2941==    by 0xA6587: have_line (gatchat.c:600)
==2941==    by 0xA6BB7: new_bytes (gatchat.c:759)
==2941==    by 0xAAFAF: received_data (gatio.c:124)
==2941==    by 0x4AF606F: g_main_dispatch (gmain.c:3154)
==2941==    by 0x4AF606F: g_main_context_dispatch (gmain.c:3769)
==2941==    by 0x4AF658F: g_main_loop_run (gmain.c:4034)
==2941==    by 0xBDDBB: main (main.c:261)
==2941==  Address 0x519c344 is 4 bytes inside a block of size 12 free'd
==2941==    at 0x4840B28: free (vg_replace_malloc.c:530)
==2941==    by 0x71F33: at_util_sim_state_query_free (atutil.c:613)
==2941==    by 0x6930B: sim_state_cb (sim.c:1297)
==2941==    by 0x71DCB: cpin_check_cb (atutil.c:567)
==2941==    by 0xA602B: at_chat_finish_command (gatchat.c:459)
==2941==    by 0xA6277: at_chat_handle_command_response (gatchat.c:521)
==2941==    by 0xA6587: have_line (gatchat.c:600)
==2941==    by 0xA6BB7: new_bytes (gatchat.c:759)
==2941==    by 0xAAFAF: received_data (gatio.c:124)
==2941==    by 0x4AF606F: g_main_dispatch (gmain.c:3154)
==2941==    by 0x4AF606F: g_main_context_dispatch (gmain.c:3769)
==2941==    by 0x4AF658F: g_main_loop_run (gmain.c:4034)
==2941==    by 0xBDDBB: main (main.c:261)
2017-10-05 19:46:32 +03:00
Slava Monich
a3301ec1d2 modem: Implement ofono_modem_get_sim 2017-10-05 19:46:31 +03:00
Slava Monich
6f11bfc632 include: Add ofono_modem_get_sim 2017-10-05 19:46:31 +03:00
Slava Monich
74262b9ef8 [ril] Don't mix slice and default allocators in ril_plugin.c
And it generally doesn't make sense to use slice allocator for allocating
the structures that are a) large and b) allocated at startup and not freed
until the program exits.
2017-10-02 17:31:47 +03:00
Slava Monich
199a610607 [ril] Fixed erroneous assert 2017-10-02 16:34:33 +03:00
Slava Monich
af2d223f0f [ofono] Moved gutil_log_func initialization from ril_plugin_init()
.. to debuglog_init(). There's no reason for it to be in RIL specific code.
2017-10-02 13:31:26 +03:00
Slava Monich
0b6fcf8b71 [mbpi] Use PROVIDER_DATABASE from config.h as the default
It's pulled from mobile-broadband-provider-info.pc by the
configure script, we should trust it.
2017-10-02 12:48:23 +03:00
Slava Monich
cc05aeccd1 Merge branch 'debug' into 'master'
Fix logging issues with external plugins

See merge request !149
2017-10-01 22:14:36 +00:00
Slava Monich
5728444ad3 [iofono] Allow to manage logs of binary plugins
External (binary) plugins have __debug section of their own.
2017-09-30 00:28:54 +03:00
Slava Monich
4cbb6b5919 [ofono] Added __ofono_plugin_foreach()
Invokes a callback for each registered plugin. It's needed by debuglog
plugin because external plugins have __debug section of their own and
debuglog needs access to debug_start and debug_stop of such plugins
in order to enable or disable plugin logs.
2017-09-29 21:27:35 +03:00
Slava Monich
5699bb4932 [build] Fixed configure check for libmce-glib
Version 1.0.5 is required for mce_display_remove_all_handlers macro
2017-09-29 13:06:34 +03:00
Slava Monich
09fa97c53a Merge branch 'default_timeout' into 'master'
Use default start timeout for default configuration

See merge request !148
2017-09-25 06:46:56 +00:00
Slava Monich
3eaa8a46bd [ril] Use default start timeout for default configuration. Fixes JB#39840
If /etc/ofono/ril_subscription.conf doesn't exist or doesn't contain
any modem sections (the latter is the case on Jolla 1 for historical
reasons) ofono falls back to the default configuration which should
use the default start timeout.
2017-09-23 18:07:57 +03:00
Slava Monich
4401319136 Merge branch 'ready' into 'master'
Set the ready flag if no drivers is registered with sailfish_manager

See merge request !147
2017-09-15 15:48:25 +00:00
Slava Monich
472ddcf0b1 Merge branch 'optionalmodem' into 'master'
Support for optional modems

See merge request !119
2017-09-15 15:48:09 +00:00
Slava Monich
b7e0f276a1 [ril] Support for optional modems. Fixes MER#1783 2017-09-15 17:14:57 +03:00
Slava Monich
5d251aea3a [ofono] More unit tests for the ready flag 2017-09-14 15:03:57 +03:00
Slava Monich
cdc0065284 [ofono] Set the ready flag if no drivers is registered with sailfish_manager. Fixes MER#1808
If there are no supported modems, ofono should be happy and the ready
flag should become true because the UI is waiting for this flag at
startup (and in this case there's nothing to wait for).
2017-09-14 15:01:45 +03:00
Slava Monich
6d65dc5bf0 Merge branch 'cellinfo' into 'master'
Move cell info API to the driver independent area.

See merge request !146
2017-09-14 08:39:03 +00:00
Slava Monich
5d02c0bba4 [ofono] Added unit test for sailfish_cell_info 2017-09-14 00:32:32 +03:00
Slava Monich
b99513e080 [ofono] Move cell info API to the driver independent area. Fixes JB#39725
So that it could be used by any driver, not just by RIL.
2017-09-14 00:29:13 +03:00
Slava Monich
3cf328c781 Merge branch 'ack' into 'master'
Support for logging new packet types (RIL v13)

See merge request !145
2017-09-12 13:36:33 +00:00
Slava Monich
bce68611a1 [ril] Support for logging new packet types (RIL v13). JB#39228 2017-09-12 00:18:52 +03:00
Slava Monich
cc497feee7 Merge branch 'online' into 'master'
Fix online state tracking

See merge request !143
2017-09-06 10:18:23 +00:00
Matti Kosola
725606af8d Merge branch 'jb39622' into 'master'
Handle normal call end with error cause.

See merge request !144
2017-09-06 08:58:25 +00:00
Juho Hämäläinen
52db6e5459 [ofono] Handle normal call end with error cause. Fixes JB#39622
With multi-sim setup we get last cause code 0xffff when incoming
call is ending due to other multi-sim phone answering the call.
Due to this handle the 0xffff as remote hangup if call status is
incoming.
2017-09-06 11:51:57 +03:00
Slava Monich
83441bc203 [ril] Fixed online state tracking. Fixes JB#39592 2017-09-05 12:14:52 +03:00
Slava Monich
4054f09b60 Merge branch 'samecaps' into 'master'
Avoid pointless radio caps switches

See merge request !142
2017-09-04 13:49:44 +00:00
Slava Monich
38aa8cff87 Merge branch 'cellinfo12' into 'master'
Support for RIL_CellInfo_v12

See merge request !141
2017-09-04 13:49:30 +00:00
Slava Monich
4959292938 [ofono] Avoid pointless radio caps switches. Fixes JB#39589
Not only it makes no sense, it can also get ofono into an infinite
switch loop.
2017-09-03 16:20:08 +02:00
Slava Monich
c69cea52cf [ofono] Support for RIL_CellInfo_v12. Fixes JB#39220
Required by RIL version 12 and above.
2017-09-03 16:12:56 +02:00
Slava Monich
4e0b8f7b48 Merge branch 'mms' into 'master'
Use REQUEST_SEND_SMS_EXPECT_MORE when appropriate

See merge request !140
2017-08-29 13:52:55 +00:00
Slava Monich
9c87063c4a [ril] Use REQUEST_SEND_SMS_EXPECT_MORE when appropriate
It's identical to RIL_REQUEST_SEND_SMS, except that more messages are
expected to be sent soon. If possible, SMS relay protocol link is kept
open (eg TS 27.005 AT+CMMS command)
2017-08-29 13:19:08 +03:00
Slava Monich
dc5a87f4f2 unit: Avoid use of uninitialised data in test-simutil
GTest: run: /testsimutil/ber tlv encode EFpnn
==16777== Conditional jump or move depends on uninitialised value(s)
==16777==    at 0x4068CB: ber_tlv_iter_next (simutil.c:369)
==16777==    by 0x406C39: ber_tlv_find_by_tag (simutil.c:483)
==16777==    by 0x407E1D: sim_eons_add_pnn_record (simutil.c:1027)
==16777==    by 0x402C39: test_ber_tlv_builder_efpnn (test-simutil.c:181)
==16777==    by 0x4EA3A80: g_test_run_suite_internal
==16777==    by 0x4EA3F9A: g_test_run_suite
==16777==    by 0x4EA3FD0: g_test_run
==16777==    by 0x4042FA: main (test-simutil.c:518)
2017-08-25 11:15:20 +03:00
Slava Monich
ecd35181a3 unit: test-sms: Fix memory leaks in the unit test 2017-08-25 01:41:06 +03:00
Slava Monich
96d6daf67e smsutil: Prevent invalid access in cbs_decode_text
Valgrind was complaining about it like this:

==18099== Conditional jump or move depends on uninitialised value(s)
==18099==    at 0x4C32281: strspn
==18099==    by 0x41286B: cbs_decode_text (smsutil.c:4140)
==18099==    by 0x40675C: test_cbs_encode_decode (test-sms.c:1417)
2017-08-25 01:38:16 +03:00
Slava Monich
e9702f6ec1 [ofono] sailfish_manager: require manager_create callback
Missing manager_create callback would cause a memory leak like this:

==9972== 96 bytes in 4 blocks are definitely lost in loss record 336 of 356
==9972==    at 0x483F3EC: malloc (vg_replace_malloc.c:299)
==9972==    by 0x4AEE0DF: g_malloc (gmem.c:94)
==9972==    by 0x4B03F51: g_slice_alloc (gslice.c:1025)
==9972==    by 0x4B0438F: g_slice_alloc0 (gslice.c:1051)
==9972==    by 0x1200B: sailfish_slot_manager_new (sailfish_manager.c:1019)
==9972==    by 0x12243: sailfish_slot_driver_init (sailfish_manager.c:1075)
==9972==    by 0x4AE906F: g_main_dispatch (gmain.c:3154)
==9972==    by 0x4AE906F: g_main_context_dispatch (gmain.c:3769)
==9972==    by 0x4AE931D: g_main_context_iterate.isra.4 (gmain.c:3840)
==9972==    by 0x4AE958F: g_main_loop_run (gmain.c:4034)
==9972==    by 0xACB7: test_basic (test-sailfish_manager.c:370)
==9972==    by 0x4B0B89F: test_case_run (gtestutils.c:2158)
==9972==    by 0x4B0B89F: g_test_run_suite_internal (gtestutils.c:2241)
==9972==    by 0x4B0BACD: g_test_run_suite_internal (gtestutils.c:2253)
2017-08-25 00:45:20 +03:00
Slava Monich
0746c615bc Merge branch 'protocol' into 'master'
Support for APN protocol in MBPI

See merge request !139
2017-08-24 21:44:36 +00:00
Slava Monich
970020a3b0 [ofono] Added tests for fetching APN protocol from MBPI. JB#39520 2017-08-24 17:45:13 +03:00
Slava Monich
f3d5e3d5c6 [ofono] mbpi: Add support for APN protocol in MBPI. Fixes #JB39520 2017-08-24 17:44:14 +03:00
Slava Monich
bb880ab14a Merge branch 'fix' into 'master'
Fix regressions after the recent huge merge

See merge request !137
2017-08-23 11:31:04 +00:00
Slava Monich
922d5e17ee [ril] Fixed a bug in ril_plugin_find_unused_slot. Fixes JB#39481
Both slots ended up with the same slot number wreaking all kinds of havoc
2017-08-23 12:40:47 +03:00
Slava Monich
7886ce04a1 [ril] Deserialize RIL I/O when SIM status becomes known. JB#39481 2017-08-23 12:39:53 +03:00
Slava Monich
5213398826 [ofono] Renamed __ofono_dbg -> ofono_dbg to allow binary plugins to use DBG macro
Only symbols starting with ofono_ can be resolved.
2017-08-22 18:11:55 +03:00
Slava Monich
0bbcc127be [ofono] Add test-sailfish_manager and test-sailfish_sim_info to the ignore list 2017-08-22 15:43:32 +03:00
Slava Monich
f7db0a0459 sms: Pass const pointer to dispatch_app_datagram 2017-08-22 15:39:28 +03:00
Slava Monich
2d18086c80 Merge branch 'sailfish_manager' into 'master'
Move Sailfish OS specific D-Bus interfaces to a separate plugin

See merge request !136
2017-08-22 12:15:27 +00:00
Slava Monich
0f4560c2eb [ofono] Moved RIL-independent stuff out of Sailfish OS RIL driver. JB#39257
The new sailfish_manager plugin contains the code necessary for
proper integration of ofono into Sailfish OS (mostly, that's
Sailfish OS specific D-Bus interfaces) and can be used by pretty
much any driver, not necessarily ril.
2017-08-22 12:07:01 +03:00
Slava Monich
7d80344d6b [ofono] network: Added ofono_netreg_get_name() function
Returns the name of the current operator.
2017-07-24 01:17:33 +03:00
Sergey Chupligin
c0c4148099 [ril] Added option to disable voicecall handling. Contributes to MER#1798 2017-07-21 15:34:39 +03:00
Slava Monich
34755f1a79 [ril] Housekeeping
Took out unnecessary include
2017-07-16 21:26:46 +03:00
Slava Monich
282d560c37 [ril] Changed the name of the common section in the error statistics file
Trying to get rid of RIL specific names, before it's too late.
2017-07-16 15:37:59 +03:00
Slava Monich
e4bca84876 [pushforwarder] Housekeeping
Removed unnecessary checks for memory allocation failures.

Replaced inotify stuff with a simpler version of the same thing -
since we already depend on libglibutil, there's no reason not to
use functions from there.
2017-07-15 12:54:15 +03:00
Slava Monich
aa0ded78b0 Merge branch 'slow_down' into 'master'
Serialize critical request sequences

See merge request !132
2017-07-13 18:40:45 +00:00
Slava Monich
eb15b12caf [ril] Don't start radio caps switch until SIM I/O calms down. JB#38689
That seems to significantly reduce the probability of a failure at startup
(we are reading the phonebook right after SIM interface is initialized)
2017-07-13 18:10:18 +03:00
Slava Monich
81b5c716e2 [ril] Notify the UI if the capability switch transaction fails. JB#38689
That bumps ModemManager protocol version to 8
2017-07-13 12:01:46 +03:00
Slava Monich
33c330988f [ril] Handle the case of one of the SIMs missing. JB#38689
LTE could be enabled for the slot that has no SIM card in it.
In that case we want to swap the capabilities so that LTE
becomes available to the slot that does have a SIM in it.
2017-07-12 19:04:26 +03:00
Slava Monich
910057a265 [ril] Make radio capability switch more reliable. JB#38689
1. Don't allow any other requests while radio caps switch is ongoing.
2. Wait for all other requests to complete before starting the switch
3. Deactivate data calls, disable data before the switch
4. Increased the timeouts
2017-07-12 17:39:40 +03:00
Slava Monich
19f0f8d96e [ril] If SET_UICC_SUBSCRIPTION times out, drop (rather than cancel) it. jb#38689
So that it gets removed from the list of pending requests and
doesn't block the next request.
2017-07-12 16:01:47 +03:00
Slava Monich
f1f3c17c4c [ril] Made PIN requests blocking. JB#38998 2017-07-12 15:58:05 +03:00
Slava Monich
29d891cbce [ril] Made SET_SUPP_SVC_NOTIFICATION blocking. JB#38998
To slow things down at startup. Some RILs just don't like it too fast.
2017-07-12 15:55:55 +03:00
Slava Monich
89fa0d5d6a [ril] Made GSM_GET_BROADCAST_SMS_CONFIG blocking. JB#38998 2017-07-12 15:53:12 +03:00
Slava Monich
c382d9f456 [ril] Poll data call state if DEACTIVATE_DATA_CALL request fails. JB#38998
Also exposed ril_request_allow_data_new and ril_request_deactivate_data_call_new
functions - those may need to be used outside of the ril_data module.
2017-07-12 15:53:01 +03:00
Slava Monich
b209b6bee6 [ril] Make RIL_REQUEST_RADIO_POWER blocking. JB#38998 2017-07-12 15:38:46 +03:00
Slava Monich
ee3323e98b [ril] Block requests while UICC subscription is in progress. JB#38998
Only allow GET_SIM_STATUS. This should make RIL happier.
2017-07-12 15:38:46 +03:00
Slava Monich
9200e387e1 [ril] Serialize requests at startup. JB#38998
Slowing things down at startup seems to make RIL happier.
2017-07-12 15:38:46 +03:00
Slava Monich
2bc58a7f6f Merge branch 'ussd' into 'master'
Switch USSD state from USER_ACTION to IDLE when a notification is received

See merge request !129
2017-06-22 07:40:18 +00:00
Slava Monich
35079b11fe [ofono] Switch USSD state from USER_ACTION to IDLE. Fixes JB#38992
When a USSD notification is received in the USER_ACTION state,
the state needs to be switched to IDLE. Some networks send 0
(no further user action required) after the response timeout
expires. That should result in the user input form getting
removed from the screen.
2017-06-21 14:57:11 +03:00
Slava Monich
955d5882b2 Merge branch 'octal' into 'master'
Workaround for broken MMS proxy IP address

See merge request !128
2017-06-20 08:14:28 +00:00
Slava Monich
2583fa99ce [ofono] Workaround for broken MMS proxy IP address. JB#38990
Some operators provide IP address of the MMS proxy
prepending zeros to each number shorter then 3 digits,
e.g. "192.168.094.023" instead of "192.168.94.23".
That may look nicer but it's actually wrong because
the numbers starting with zeros are interpreted as
octal numbers. In the example above 023 actually means
16 and 094 is not a valid number at all.

In addition to publishing these broken settings on their
web sites, some of the operators send them over the air,
in which case we can't even blame the user for entering
an invalid IP address. We better be prepared to deal with
those.

Since nobody in the world seems to be actually using the
octal notation to write an IP address, let's remove the
leading zeros if we find them in the host part of the MMS
proxy URL.
2017-06-19 18:47:20 +03:00
Slava Monich
b8bb15ce9c [ril] Fixed voicecall problem introduced by commit 351ac1e9. JB#38105 2017-06-17 18:53:16 +03:00
Slava Monich
cbf24c7b08 Merge branch 'auth_method' into 'master'
Add ANY and NONE authentication methods

See merge request !126
2017-06-17 14:13:16 +00:00
Slava Monich
a4c4d1526e [ofono] Reset authentication method together with other context settings. JB#38972 2017-06-16 17:38:32 +03:00
Slava Monich
18d1a8834a [rpm] Require mobile-broadband-provider-info at runtime
Even though it's not really required at build time anymore, let's still
keep it there because this requirement is hardcoded in configure.ac which
we pull from upstream.
2017-06-16 17:05:33 +03:00
Slava Monich
8343d96db5 [test] Improved provisioning test coverage
It no longer requires mobile-broadband-provider-info package to run
2017-06-16 17:04:28 +03:00
Slava Monich
415fce9368 [ofono] Allow to compile unit tests with coverage enabled
... and added unit/coverage script which runs the tests and
generates html report.

Code coverage has to be enabled with --enable-test-coverage
configure switch
2017-06-16 17:04:28 +03:00
Slava Monich
33257a139d [ril] Respect the authentication algorithm option. JB#38972 2017-06-16 17:04:28 +03:00
Slava Monich
f580867c12 [ofono] Added ANY and NONE authentication methods. JB#38972
ANY is supposed to allow either PAP or CHAP to be performed at plugin's
discretion. This is now the default (rather than CHAP)

NONE disables the authentication alltogether.
2017-06-16 17:03:40 +03:00
Slava Monich
edaba80ad1 Merge branch 'imeisv' into 'master'
Expose IMEI SV via org.nemomobile.ofono.ModemManager

See merge request !127
2017-06-16 09:07:49 +00:00
Slava Monich
e68314b07d [ofono] Expose IMEI SV via org.nemomobile.ofono.ModemManager. JB#38973
Unlike org.ofono.Modem properties, it's always going to be available
even for the slots that are disabled.
2017-06-15 15:30:03 +03:00
Slava Monich
d13e48b638 Merge branch 'radio_caps' into 'master'
Start using RIL_REQUEST_SET_RADIO_CAPABILITY

See merge request !122
2017-06-15 11:53:27 +00:00
Slava Monich
e0edfca358 [ril] Added SetRadioCapability config option. JB#38689
The RIL_REQUEST_SET_RADIO_CAPABILITY request is still not supported
by some relatively recent RILs, it should be possible to forcibly
turn it off.
2017-06-14 17:54:34 +03:00
Slava Monich
7cd2075ada [ril] Start using SET_RADIO_CAPABILITY. Fixes JB#38689
With some RILs it seems to be the only way to let all slots to use 4G,
SET_PREFERRED_NETWORK_TYPE is not always enough.
2017-06-14 17:50:51 +03:00
Slava Monich
3ccacfd5f7 [ril] Notify rild when we don't need mobile data. JB#38689
We were only telling rild when we need mobile data, but we should also
tell it when we don't need it.
2017-06-11 21:27:28 +03:00
Slava Monich
5ee13f8e2c [rpm] Drop the .changes file
It's not being maintained.
2017-06-11 16:09:09 +03:00
Slava Monich
6ab9dcb553 Merge branch 'sailfish_plugins' into 'master'
Consistent naming of Sailfish OS specific plugins

See merge request !125
2017-06-11 13:08:19 +00:00
Slava Monich
102061107a [ofono] push-forwarder -> sailfish-pushforwarder. Fixes JB#38927
The configure option --enable-sailfish-pushforwarder is now required in order
to enable this plugin (it was enabled by default)
2017-06-11 15:56:03 +03:00
Slava Monich
2bb7d629f5 [ofono] debuglog plugin -> sailfish_debuglog. JB#38927 2017-06-11 15:47:43 +03:00
Slava Monich
5ce01787e8 [ofono] Renamed jolla-rilmodem configure option into sailfish-rilmodem. JB#38927 2017-06-11 15:42:30 +03:00
Slava Monich
1d57cb0e73 [ofono] Renamed sailfishos configure option to sailfish-bt. JB#38927
Also, renamed sfos_bt.c into sailfish_bt.c so that the file name
looks similar to the configure option that enables it.
2017-06-11 15:41:56 +03:00
Slava Monich
3d84c0a120 [ofono] Renamed Sailfish OS specific provision plugin to sailfish_provision. JB#38927
plugins/provision.c is the original upstream provisioning plugin and
plugins/sailfish_provision.c is the Sailfish OS specific thing. They
are mutually exclusuve.

Sailfish OS specific plugin is enabled with --enable-sailfish-provision
configure switch. By default, the upstream plugin is used.
2017-06-11 15:40:57 +03:00
Slava Monich
091cf21c0b Merge branch 'hangup' into 'master'
Keep hangup D-Bus request pending until RIL hangup completes

See merge request !123
2017-06-08 09:58:44 +00:00
Slava Monich
351ac1e9db [ril] Keep hangup D-Bus request pending until RIL hangup completes. JB#38105 2017-06-07 16:49:57 +03:00
Slava Monich
b7481a918f radio-settings: Fix memory leaks in radio_load_settings
Errors returned by g_key_file_get_integer have to be deallocated
by the caller to avoid leaks like these:

==13330== 104 (24 direct, 80 indirect) bytes in 2 blocks are definitely lost
==13330==    at 0x483F3EC: malloc (vg_replace_malloc.c)
==13330==    by 0x4B020DF: g_malloc (gmem.c)
==13330==    by 0x4B17F51: g_slice_alloc (gslice.c)
==13330==    by 0x4AE80B9: g_error_new_valist (gerror.c)
==13330==    by 0x4AE830B: g_set_error (gerror.c)
==13330==    by 0x4AF5681: g_key_file_get_value (gkeyfile.c)
==13330==    by 0x4AF6817: g_key_file_get_integer (gkeyfile.c)
==13330==    by 0x10CFE3: radio_load_settings (radio-settings.c)
==13330==    by 0x10D2E3: ofono_radio_settings_register (radio-settings.c)
2017-06-02 21:23:23 +03:00
Slava Monich
e1e4381105 Merge branch 'default_data_sim' into 'master'
Don't auto-select the data sim on a multisim phone

See merge request !121
2017-05-31 07:59:32 +00:00
Slava Monich
cc3ca52e61 [ril] Don't auto-select the data sim on a multisim phone. JB#38719
This kind of behavior is reserved for single sim phone (for now).
2017-05-30 16:44:15 +03:00
Slava Monich
a71779ea2a [ril] Added assert in ril_sim_card_status_parse
.. that we have parsed the entire parcel to the end
2017-05-26 12:10:04 +03:00
Slava Monich
a9d2849bbb Merge branch 'jb38795' into 'master'
Fix passing -j to make

See merge request !120
2017-05-25 13:38:34 +00:00
Martin Kampas
ca29c8e538 [packaging] Fix passing -j to make. Contribute to JB#38795 2017-05-25 14:28:18 +02:00
Slava Monich
85fe1b7174 Merge branch 'imei' into 'master'
Use RIL_REQUEST_DEVICE_IDENTITY  instead of RIL_REQUEST_GET_IMEI

See merge request !117
2017-05-12 21:17:02 +00:00
Slava Monich
56e0d9dffa Merge branch 'file_watches' into 'master'
Prevent a crash in sim_fs_notify_file_watches

See merge request !118
2017-05-12 20:33:58 +00:00
Slava Monich
6867ba65cb [simfs] Prevent a crash in sim_fs_notify_file_watches. Fixes JB#38656
If no file watchers have ever been added, context->file_watches
is NULL and sim_fs_notify_file_watches() should take that into
account.
2017-05-12 18:51:53 +03:00
Slava Monich
6199eaa4d8 [ril] Allow (some) DEVICE_IDENTITY requests to time out. Fixes JB#38632
If GET_SIM_STATUS succeeds but DEVICE_IDENTITY keeps on failing,
allow the latter to time out. Some RILs behave that way until the
modem has been properly initialized.
2017-05-12 17:21:40 +03:00
Slava Monich
fabdd6799c [ril] Use DEVICE_IDENTITY request instead of GET_IMEI. Contributes to JB#38632
RIL_REQUEST_GET_IMEI has been deprecated since 2009
2017-05-12 17:15:01 +03:00
Slava Monich
1219ab6a3f Merge branch 'permlock' into 'master'
Detection of permanently locked SIM cards

See merge request !116
2017-04-28 16:13:23 +00:00
Slava Monich
85a956d9eb [ril] Improved detection of permanently locked SIM cards. JB#38257
If PUK is required, app state is PUK and pin1_state is ENABLED_BLOCKED.
If the card is permanently locked, app state is still PUK but pin1_state
becomes ENABLED_PERM_BLOCKED. That way we can tell whether the SIM card
is locked even if the number of remaining attempts is not available.
2017-04-28 16:06:22 +03:00
Slava Monich
c83d992a3b Merge branch 'retries' into 'master'
Query PUK retry count

See merge request !115
2017-04-28 11:54:09 +00:00
Slava Monich
b22027017c [ril] Query PUK retry count. JB#38257
PUK retry counts can be queried in a way similar to PIN retry counts
on those RILs that support it.
2017-04-27 21:36:46 +03:00
Slava Monich
1fa137b36d [sim] Allow plugins to use puk2pin() function 2017-04-27 21:27:27 +03:00
Slava Monich
cfd837b1db Merge branch 'puk' into 'master'
Always refresh SIM status from query_passwd_state

See merge request !114
2017-04-27 08:08:20 +00:00
Slava Monich
735ad21e89 [ril] Always refresh SIM status from query_passwd_state. Fixes JB#38257
After we have entered an invalid pin too many times, RIL signals
the SIM status change, we request the new status but ofono core
asks us for the new passwd state before our SIM status query has
completed. We need to wait for the query to complete before we can
report the new status to the core.

It also won't hurt if we request a fresh SIM status every time
when query_passwd_state callback is called, just in case if RIL
fails to notify us about the SIM status change.
2017-04-26 15:03:26 +03:00
Slava Monich
c9078404de [ril] Housekeeping 2017-04-14 19:51:42 +03:00
Slava Monich
e375195c92 Merge branch 'tech' into 'master'
Add "technologies" configuration option

See merge request !111
2017-04-10 21:10:22 +00:00
Slava Monich
ef5610f741 [ril] Added "technologies" configuration option. Fixes JB#38295
It supersedes enable4G option.
2017-04-05 21:18:00 +03:00
jpoutiai
aef9bbd3e0 Merge branch 'jb38053' into 'master'
[plugins] support bt call audio control. Fixes JB#38053

See merge request !110
2017-04-05 10:23:27 +00:00
Jarko Poutiainen
c6eb410f21 [plugins] support bt call audio control. Fixes JB#38053 2017-04-05 08:35:55 +03:00
Slava Monich
08b3ea3d0f Merge branch 'last_fail' into 'master'
Handle fancy variant of LAST_CALL_FAIL_CAUSE response

Some RILs get creative and invent their own formats.
They must be very proud of it.

See merge request !106
2017-03-15 21:46:11 +00:00
Slava Monich
2978862417 [ril] Handle fancy variant of LAST_CALL_FAIL_CAUSE response. Fixes JB#38079
Some RILs get creative and invent their own formats.
2017-03-15 17:19:37 +02:00
Slava Monich
19228c9e67 Merge branch 'lastcause' into 'master'
Allow to configure custom hangup reasons

One can define localHangupReasons and remoteHangupReasons in
ril_subscription.conf which will be treated as normal local or
remote hangup reasons.

See merge request !104
2017-02-24 13:11:46 +00:00
Slava Monich
9be791d531 [ofono] Allow to conifigure custom hangup reasons. Fixes JB#37879
One can define localHangupReasons and remoteHangupReasons in
ril_subscription.conf which will be treated as normal local or
remote hangup reasons. The value is a comma-separated list of
numbers, e.g.

localHangupReasons=20,39
2017-02-24 12:07:57 +02:00
Slava Monich
6b9eb7bf8f Merge branch 'voicecall' into 'master'
Don't use internal voicecall data structures

Added ofono_voicecall_find_call API instead

See merge request !105
2017-02-24 10:06:39 +00:00
Slava Monich
01f8989aee [ril] Don't use internal voicecall data structures
Use newly added ofono_voicecall_find_call API instead
2017-02-24 00:28:50 +02:00
Slava Monich
2f5efaf591 [ofono] Added ofono_voicecall_find_call API
For use by plugins
2017-02-24 00:28:18 +02:00
Slava Monich
ca1d06c37a Merge branch 'disable' into 'master'
Disable some unnecessary and harmful functionality

See merge request !103
2017-01-12 15:17:23 +00:00
Slava Monich
5f45928a84 [ofono] Disable PhoNet/ISI and QMI modem support. MER#1734
This makes ARM executable smaller by 170 KB
2017-01-12 00:47:04 +02:00
Slava Monich
19f74e6c85 [ofono] Don't allow to add or remove connection context over D-Bus. Fixes MER#1733
Quite a few things in SailfishOS assume that each modem has exactly
one internet and one mms context. However, ofono's D-Bus API allows
any application to arbitrarily add and remove connection contexts
which can screw things up quite badly. Since this functionality is
not used by SailfishOS, it should be disabled.
2017-01-12 00:27:17 +02:00
Slava Monich
41d5cfcab2 Merge branch 'modem-error' into 'master'
Count rild crashes

See merge request !102
2017-01-11 11:58:42 +00:00
Slava Monich
357c5db580 [ril] Count rild crashes. Contributes to JB#35780
org.nemomobile.ofono.ModemManager.ModemError signal is emitted
when rild crash is detected. Also, the new GetModemErrors method
allows to query how many times which instance of rild has crashed
since ofono was (re)started.
2017-01-11 13:24:23 +02:00
Slava Monich
8cea5b9f96 [ril] Allow to retry GET_BROADCAST_SMS_CONFIG. MER#1729
RIL_REQUEST_GSM_GET_BROADCAST_SMS_CONFIG sometimes fails at startup.
We may have to retry a few times (typically, once or twice on Jolla 1)
2017-01-05 18:40:50 +03:00
Slava Monich
5fb35d5fb4 Merge branch 'v1.19' into 'master'
Update ofono baseline to 1.19

It's the latest stable release.

See merge request !101
2017-01-05 12:39:13 +00:00
Slava Monich
e8d57bb928 [ofono] Update baseline to 1.19
Removed merge artifacts
2017-01-05 15:37:58 +03:00
Slava Monich
2bfde2418e [ril] Removed old workaround breaking hot-swap. Fixes MER#1730
The workaround is no longer needed. All SIM I/O requests have to
be completed even if the SIM card is removed while the request is
pending. Otherwise simfs request queue gets stuck.
2017-01-05 15:35:29 +03:00
Marcel Holtmann
c710ce76c1 Release 1.19 2017-01-05 11:20:08 +03:00
Alfonso Sánchez-Beato
78acd90464 gitignore: unit/test-rilmodem-gprs binary 2017-01-05 11:20:08 +03:00
Alfonso Sánchez-Beato
e51b3ca0c8 build: add rilmodem gprs unit tests
Conflicts:
	ofono/Makefile.am
2017-01-05 11:20:08 +03:00
Alfonso Sánchez-Beato
b3c8813bd4 unit: add rilmodem gprs tests
Add rilmodem gprs tests, which use the rilmodem test engine.
2017-01-05 11:20:08 +03:00
Alfonso Sánchez-Beato
e2a3acd9d0 unit: add rilmodem test engine
Add rilmodem test engine. This engine is an improvement on the rilmodem
test server that allows us to test generic interactions with the
rilmodem driver. Instead of just be able to check content of received/
sent bytes on the rild socket, we can now specify a set of steps for a
test that include interactions with the atom. The step types are

- TST_ACTION_SEND: The harness sends a parcel
- TST_ACTION_CALL: The harness calls a driver function
- TST_EVENT_RECEIVE: The driver sends a parcel
- TST_EVENT_CALL: The driver calls a harness (atom) function
2017-01-05 11:20:08 +03:00
Slava Monich
2054ca9570 include: Remove unused field from primary_context 2017-01-05 11:20:08 +03:00
Denis Kenzior
48dbb7912a AUTHORS: Mention Antoine's contributions 2017-01-05 11:20:08 +03:00
Denis Kenzior
d7e7ad671d gatchat: Fix style 2017-01-05 11:20:08 +03:00
Antoine Aubert
5b5a86dc80 gatmux: fix read channel remove on error
In case of invalid IO, read_watch is not reset. This fix crash on
destroy gatmux.
2017-01-05 11:20:08 +03:00
Slava Monich
c232524e99 main: Make -d option repeatable
Concatenating the patterns makes more sense than using the last
supplied value and leaking the previous allocated patterns.
2017-01-05 11:20:08 +03:00
Frédéric Dalleau
bfd09a5c14 udevng: Detect huawei E3372 modem and pcui
When the modes are modified with AT^SETPORT="FF;12,1,16", this modem
and pcui will appear using different ids. Update the interfaces
identifier accordingly.
2017-01-05 11:20:08 +03:00
Frédéric Dalleau
f8adcd2550 udevng: Detect huawei E3372 pcui
The huawei E3372 exposes two USB tty at /dev/ttyUSB0 and /dev/ttyUSB1
/dev/ttyUSB1 is properly detected as modem.
/dev/ttyUSB0 is the pcui.

lsusb shows 12d1:1506 Huawei Technologies Co., Ltd. Modem/Networkcard
2017-01-05 11:20:08 +03:00
Denis Kenzior
2a97567147 handsfree-audio: Fix crash
For HFP 1.5 devices the driver is always set to NULL.  So if the AG
establishes the SCO connection first, we might crash.
2017-01-05 11:20:07 +03:00
Santtu Lakkala
04d84b615e huaweimodem: Fix DHCP parsing on 32-bit platforms
strtol clamps returned value between INT_MIN and INT_MAX, causing
invalid value (255.255.255.127) being reported for any address
if last octet > 127 when sizeof(long) == 4.
2017-01-05 11:20:07 +03:00
Samrat Guha Niyogi
6e34792323 sim: remove locked_pin reset from sim_free_main_state 2017-01-05 11:20:07 +03:00
Samrat Guha Niyogi
d6a59f5dc4 rilmodem: fix cbd init in ril_query_facility_lock 2017-01-05 11:20:07 +03:00
Samrat Guha Niyogi
23e299055f rilmodem: fix num_params in query_facility_lock_cb 2017-01-05 11:20:07 +03:00
Denis Kenzior
a56ef3ba0f rilmodem: Co-locate the callback with invocation 2017-01-05 11:20:07 +03:00
Denis Kenzior
7294433906 rilmodem: Co-locate the callback with invocation 2017-01-05 11:20:07 +03:00
Samrat Guha Niyogi
d7263cd344 rilmodem: split ril_pin_change_state_cb
split ril_pin_change_state_cb based on functionality w.r.t.
facility lock, puk and pin. Rename ril_pin_change_state to
more appropriate name ril_set_facility_lock and rename
ril_pin_change_state_cb to ril_enter_sim_pin_cb.
2017-01-05 11:20:07 +03:00
Samrat Guha Niyogi
2f3b469fbb rilmodem: Remove unneeded pin sending logic 2017-01-05 11:20:07 +03:00
Denis Kenzior
4187e7ee8f sim: Fix style 2017-01-05 11:20:07 +03:00
Samrat Guha Niyogi
4d3f89bae0 sim: query facility during initialization in chain manner
query facility during initialization is modified from back
to back invocation to chain manner to keep it inline with
RIL design. All vendor RIL does not support back to back
handling since RIL telephony framework sends the request
synchronously.
2017-01-05 11:20:07 +03:00
Denis Kenzior
cbd1c5d524 sim: return false for SIM_PASSWORD_NONE 2017-01-05 11:20:07 +03:00
Ankit Navik
7976e44746 ril_sofia3gr: use vendor modem power down command 2017-01-05 11:20:07 +03:00
Denis Kenzior
3d6e220686 test: Add cancel-sms script 2017-01-05 11:20:07 +03:00
Denis Kenzior
919526d392 test: Fix permissions 2017-01-05 11:20:07 +03:00
Anirudh Gargi
b7082146e8 gril: Fix print macros to use latest print_buf 2017-01-05 11:20:07 +03:00
Denis Kenzior
094a296a14 AUTHORS: Mention Rajagopal's contributions 2017-01-05 11:20:07 +03:00
Rajagopal Aravindan
5c259e751b test: Added test to disable sofia 3gr tx throttling 2017-01-05 11:20:07 +03:00
Rajagopal Aravindan
69e5d5b356 test: Added test to enable sofia 3gr tx throttling 2017-01-05 11:20:07 +03:00
Rajagopal Aravindan
56e7d0e8ea ril_sofia3gr: Add transmit power throttling
Added 'sofia3gr.ThermalManagement' interface to sofia3gr plugin and
floated 'TransmitPowerThrottling' as an ofono property under that,
to support modem throttling.

'sofia3gr.ThermalManagement'
    1.Will be available ONLY if modem throttling is supported in RIL.
      This is determined by sending a RIL request during ofono start,
      to get current throttling state. If it succeeds, interface is
      published otherwise not.

'TransmitPowerThrottling'
    1.GetProperties will be allowed both when modem is ON & OFF.
    2.GetProperties will be serviced by looking it up from state
      information maintained inside ofono. No RIL call will be made.
    3.SetProperty will be allowed ONLY when modem is ON.
    4.SetProperty request will be forwarded to RIL ONLY if
      new state != current state. If RIL request succeeds, state
      information will be updated and also, a property change signal
      will be emitted.
2017-01-05 11:20:07 +03:00
Nishanth V
bb2ae6d1a1 rilmodem: fix WCDMA only in query rat mode 2017-01-05 11:20:07 +03:00
Caiwen Zhang
cf7692db49 plugins/ril: enable cbs 2017-01-05 11:20:07 +03:00
Caiwen Zhang
63f3311cd6 rilmodem: add cell broadcast message support 2017-01-05 11:20:07 +03:00
Samrat Guha Niyogi
c5aae77d41 ril_sofia3gr: Return -EINPROGRESS on disable() 2017-01-05 11:20:07 +03:00
Denis Kenzior
f8e21c8ad4 AUTHORS: Mention Suman's contributions 2017-01-05 11:20:07 +03:00
Suman Mallela
8e6dfe433b rilmodem: Fix PIN retries logic
The SIM PIN retries were not getting reset when the correct PIN/PUK
was entered.
2017-01-05 11:20:07 +03:00
Caiwen Zhang
ae23bb552b gril: avoid glib runtime warning
gril may be destroyed in the request callback (e.g in the callback of
set modem power off request). 'out_queue' and 'command_queue' is NULL.
there will be glib runtime warning if use them.
2017-01-05 11:20:06 +03:00
Caiwen Zhang
2becd051d4 plugins/ril: complete modem power off process 2017-01-05 11:20:06 +03:00
Slava Monich
8cfb1d5ca3 Merge branch 'cbs' into 'master'
Enable Cell Broadcast support

It was totally broken. 

See merge request !100
2017-01-05 08:15:45 +00:00
Slava Monich
50f35458f6 Merge branch 'rat' into 'master'
Preferred network mode, more corner cases

See merge request !99
2017-01-05 08:14:43 +00:00
Slava Monich
51843accf7 [ril] Enable Cell Broadcast support. Fixes MER#1729 2017-01-04 20:34:54 +03:00
Slava Monich
fb856dc7d6 [ril] Preferred network mode, more corner cases. Contributes to JB#36683
Prevents repeated rat mode setting failures when data SIM is not selected.
2017-01-04 16:05:11 +03:00
Slava Monich
1482748183 Merge branch 'silent-retry' into 'master'
Retry data call more than once

See merge request !98
2016-12-10 18:16:16 +00:00
Slava Monich
869ffda61e [ofono] Retry data call more than once. Contributes to JB#35406
Sometimes one retry is not enough, we need to allow more.
The first retry occurs immediately, then short delays are
applied. The delays and the number of retries are configurable.
The default is 4 retries and 200 ms delay before each retry
(except for the first one).

That should reduce the number of "Problem with connection" banners
thrown into the user's face.
2016-12-09 18:32:46 +02:00
Slava Monich
f875cbfda2 [ril] A few debug log changes 2016-12-08 18:20:43 +02:00
Slava Monich
2a60eaa6e3 Merge branch 'radiosetting' into 'master'
Fix the problem with radio settings saved to the wrong place

After the baseline was upgraded to 1.18, ofono core started saving
its radio settings to a file, and in order to save it to the right
place, the radio settings module needs to know the IMSI. So we have
to make sure that IMSI is available when we register the radio
settings atom.

See merge request !97
2016-11-25 13:41:02 +00:00
Slava Monich
29b6c41d48 [ril] Register ofono radio settings only when IMSI is available. Fixes MER#1708
Otherwise its radiosetting files gets written directly to /var/lib/ofono
instead of the SIM specific subdirectory.
2016-11-25 01:57:19 +02:00
Slava Monich
2f6491d005 [ril] Reset imsi in ril_sim_settings to NULL when SIM is removed. 2016-11-25 01:56:33 +02:00
Slava Monich
1a25047e9d Merge branch 'jb36957' into 'master'
Fix receiving UTF-16 encoded messages with split 4-byte char.

See merge request !96
2016-11-18 16:58:17 +00:00
Martin Jones
899e14bf17 [ofono] Fix receiving UTF-16 encoded messages with split 4-byte char. Fixes JB#36957
The spec supports UCS2, but in reality UTF-16 is used, which supports
4-byte characters, which could be split into different message
fragments. Accumulate the entire UTF-16 message before converting to
UTF8.
2016-11-18 14:06:57 +02:00
Slava Monich
2520664c63 Merge branch 'gprs-picks' into 'master'
Couple of upstream picks

One of those eliminates a possible root cause of mobile data
becoming disabled under certain (fairly rare) circumstances.

See merge request !95
2016-11-07 09:43:04 +00:00
Slava Monich
445bbbd66f gprs: Check GPRS_FLAG_ATTACHED_UPDATE
... in pri_deactivate_callback

This prevents attached state from getting stuck at 0 like this:

1. Context deactivation is initiated over D-Bus, ctx->pending is set
2. Attached becomes FALSE, context is still marked as active
3. Attached becomes TRUE, gprs_attached_update sets GPRS_FLAG_ATTACHED_UPDATE
4. Deactivation completes, attached is 0, driver_attached is 1

Futher network status updates don't call gprs_attached_update because
driver_attached is still 1, so attached is staying 0 until we lose the
data registration again which may not happen for quite a long time.
2016-11-04 12:14:48 +03:00
Caiwen Zhang
08fc4b0d03 gprs: fix crash removing a context being activated
If remove the context before context activation is completed, it may
cause a crash.
2016-11-04 12:14:18 +03:00
Slava Monich
c82e94ffb4 Merge branch 'cancel' into 'master'
Make sure that data request completion callback is always called on cancel

See merge request !94
2016-10-31 16:12:52 +00:00
Slava Monich
fd3712940b [ril] Make sure data request completion callback is called on cancel. Contributes to JB#33640
Completion callback wasn't invoked if the data request was cancelled
before it was actually submitted to RIL.
2016-10-28 15:46:06 +03:00
Slava Monich
8410c985c9 Merge branch 'nitz' into 'master'
Handle NITZ information coming before MCC/MNC

See merge request !93
2016-10-27 09:26:05 +00:00
Slava Monich
0878decdc0 Merge branch 'prefmode' into 'master'
Preferred network mode, corner cases

See merge request !92
2016-10-27 09:25:18 +00:00
Slava Monich
cb69984722 [ril] Preferred network mode, corner cases. Fixes JB#36683
Really make sure that we don't try to set preferred network mode to LTE
for more than one slot at a time.
2016-10-26 17:30:01 +03:00
Slava Monich
1fe8701f1a [nettime] Handle NITZ information coming before MCC/MNC. Fixes MER#1680
Due to the order in which events are delivered and network registration
information requiring one extra query, NITZ information may be delivered
to ofono before MCC/MNC are known.
2016-10-26 16:56:30 +03:00
Slava Monich
c5286fee70 Merge branch 'rat' into 'master'
Check network mode after ril_data is created

Not sure if it completely fixes the issue but it could cause
repeating SET_PREFERRED_NETWORK_TYPE failures.

See merge request !91
2016-10-23 21:04:29 +00:00
Slava Monich
3c5f6f84e1 Merge branch 'data_calls' into 'master'
Make data call format configurable

Different RILs use different data call structures which don't
necessarily match the format specified in the data list header.
The header may have version 9 but the list may contain 
RIL_Data_Call_Response_v6` structures, list version 10 may
contain RIL_Data_Call_Response_v11 and so on. By default ofono
assumes that the version from the list header matches the contents
but sometimes you have to explicitly tell ofono which one to use.

Possible values are 6, 9, 11 and auto.

See merge request !90
2016-10-23 21:03:52 +00:00
Slava Monich
8b87b55e8d [ril] Check network mode after ril_data is created. Contributes to JB#36683 2016-10-20 14:41:29 +03:00
Slava Monich
bce34cbff3 [ril] Housekeeping
Removed unnecessary forward declaration
2016-10-20 14:38:04 +03:00
Slava Monich
f8351cacf1 [ril] Made data call format configurable. Contributes to MER#1679
This commit adds dataCallFormat configuration option to
ril_subscriptuion.conf which allows to select which data
call format to use. There are quite a few rils where version
provided in the data call list header doesn't match the contents.
2016-10-19 12:30:13 +03:00
Slava Monich
6b9b8583dc Merge branch 'v10' into 'master'
Assume RIL_Data_Call_Response_v11 for RIL version 10

See merge request !89
2016-10-18 13:15:37 +00:00
Slava Monich
1df56480ba [ril] Assume RIL_Data_Call_Response_v11 for RIL version 10. Fixes MER#1679
All known rils that report version 10 are using RIL_Data_Call_Response_v11
(FairPhone 2, Nexus 4).
2016-10-18 15:11:00 +03:00
Slava Monich
adc8fce399 Merge branch 'v1.18' into 'master'
Update to upstream 1.18

This pulls the baseline from 1.17 to 1.18

See merge request !87
2016-10-17 12:08:43 +00:00
Slava Monich
d24ce4d9de Merge branch 'prefmode' into 'master'
Query preferred network mode at startup

Not knowing the initial state may result in endless attempts to
switch to LTE, failing because the other slot has LTE on.

See merge request !88
2016-10-17 12:07:35 +00:00
Slava Monich
f726af3309 [spec] Bumped version 2016-10-14 23:24:22 +03:00
Slava Monich
0ba1fd641b [ril] Query preferred network mode at startup
Not knowing the initial state may result in endless attempts to switch
to LTE, failing because the other slot has LTE on.
2016-10-14 20:46:39 +03:00
Slava Monich
41c0b0a2e6 Fixed merge artifact that was breaking OBS build 2016-10-14 20:18:47 +03:00
Slava Monich
322282258a netmon: Make sure we don't pass NULL message to g_dbus_send_message 2016-10-14 19:34:32 +03:00
Slava Monich
f6a7c39bba [ril] Added support for org.ofono.NetworkMonitor interface
Even though it's not as useful as org.nemomobile.ofono.CellInfo
it has the advantage of being the official one.
2016-10-14 19:33:07 +03:00
Denis Kenzior
3d3f68c798 allowed-apns: Fix crash
When a modem is being removed, all of the modem's atom watches have
already been cleaned up.  Trying to remove it again results in a crash.

Fix by registering a destroy callback which will be notified when the
atomwatch has been removed.
2016-10-14 19:00:35 +03:00
Nishanth V
e8d057c39e plugins: Fix allowed apn plugin exit 2016-10-14 19:00:28 +03:00
Slava Monich
357e5b69ca [update] Update to upstream 1.18. Fixes MER#1673 2016-10-14 17:09:35 +03:00
Slava Monich
e77efed603 [ofono] Fixed compilation after 1.18 merge 2016-10-14 17:09:00 +03:00
Marcel Holtmann
fa252b8d4a Release 1.18 2016-10-14 17:04:11 +03:00
Caiwen Zhang
321c092d6b plugins/ril: enable STK 2016-10-14 17:04:11 +03:00
Caiwen Zhang
ee912bafe3 rilmodem/stk: add STK support for rilmodem 2016-10-14 17:04:11 +03:00
Denis Kenzior
35eb528a70 gobi: Fix warning
plugins/gobi.c: In function ‘gobi_pre_sim’:
plugins/gobi.c:431:2: error: ‘sim_driver’ may be used uninitialized in
this function [-Werror=maybe-uninitialized]
  ofono_sim_create(modem, 0, sim_driver, data->device);
    ^
2016-10-14 17:04:11 +03:00
Denis Kenzior
22a6c4438b udevng: Fixup various minor style issues 2016-10-14 17:04:11 +03:00
Martin Chaplet
652bdc15ad udevng: Add support for Sierra MC73xx QMI modems
Udevng layer is changed in order to support Sierra QMI modems like
MC73cxx. Identically to Huawei modems, these modems are parsed by
setup_sierra. If QMI interface is detected, the Gobi modem driver is
selected.

Unfortunately, MC73xx chips seem to have a broken QMI UIM interface.
The qmimodem-legacy is so forced in setup function.
2016-10-14 17:04:11 +03:00
Martin Chaplet
a71e277850 udevng: Improve modem properties detection
* Add driver's subsystem information (net, usb, tty, ...)
 * Improve interface number extraction by scanning also device and
 parent attributes
2016-10-14 17:04:11 +03:00
Martin Chaplet
fbee06e8be gobi: Enable SIM driver forcing
Some gobi devices do not actually support UIM interface.  So if the
"ForceSimLegacy" property is set, force the qmimodem-legacy SIM driver.
2016-10-14 17:04:11 +03:00
Denis Kenzior
26029566e2 AUTHORS: Mention Martin's contributions 2016-10-14 17:04:11 +03:00
Martin Chaplet
0074ff2660 udevng: Add usbmisc scan for QMI devices
cdc-wdm0 are now usbmisc devices
2016-10-14 17:04:10 +03:00
Denis Kenzior
82fa5e977a radio-settings: Fix style 2016-10-14 17:04:10 +03:00
Antara Borwankar
823f13a1fa radio-settings: Init pending_band_{gsm|umts}
The set_band method takes two parameters for band settings, one for gsm
and one for umts.  When loaded from storage, and they are not set to
defaults, the band variables can get out of sync when setting the
GsmBand and UmtsBand properties.
2016-10-14 17:04:10 +03:00
Denis Kenzior
7b34498b1e rilmodem: Remove no longer relevant TODO 2016-10-14 17:04:10 +03:00
Denis Kenzior
37d4e1983b include: Remove unused query_locked method
Conflicts:
	ofono/include/sim.h
2016-10-14 17:04:09 +03:00
Denis Kenzior
e6f26f3bcf rilmodem: Fix style 2016-10-14 17:00:59 +03:00
Samrat Guha Niyogi
23e1d2c516 rilmodem: Implement sim atom query_facility_lock 2016-10-14 17:00:59 +03:00
Samrat Guha Niyogi
1f246cc28c include: Add query_facility_lock method
Conflicts:
	ofono/include/sim.h
2016-10-14 17:00:56 +03:00
Caiwen Zhang
ec20f44124 doc: Fix enumeration value to be gprs and not gsm 2016-10-14 16:57:35 +03:00
Denis Kenzior
8b6139aea8 radio-settings: Fix 80-character limit 2016-10-14 16:57:35 +03:00
Denis Kenzior
b79c3c3a95 AUTHORS: Mention Antara's contributions 2016-10-14 16:57:35 +03:00
Antara Borwankar
c885744273 radio-settings: Store GSM and UMTS band settings 2016-10-14 16:57:35 +03:00
John Ernberg
cdd0e4eaff stk: clean up undefined function pointer casts 2016-10-14 16:57:35 +03:00
John Ernberg
402783f877 configure: Bump glib dependecy to 2.32
Needed to support g_queue_free_full
2016-10-14 16:57:35 +03:00
Denis Kenzior
4755990237 ril_sofia3gr: Add quirk to radio_settings atom 2016-10-14 16:57:35 +03:00
Denis Kenzior
7a91b4e069 ril: vendorize SoFiA set_band implementation
Since the set_band implementation uses an OEM hook, it should be wrapped
behind a vendor quirk.
2016-10-14 16:57:35 +03:00
Antara Borwankar
35d4ca1e53 rilmodem: Driver code to set band mode and value
set_band driver to set GSM band and UMTS band
2016-10-14 16:57:35 +03:00
John Ernberg
ea334e9daa simfs: Remove explicit casts 2016-10-14 16:57:35 +03:00
John Ernberg
16964bb8f2 sim: Remove explicit casts 2016-10-14 16:57:35 +03:00
John Ernberg
0b93ab2d76 phonebook: Remove explicit casts
Casting between incompatible function pointer types is undefined.  So
remove such casts when possible.
2016-10-14 16:57:35 +03:00
John Ernberg
0bed313ecb unit: Use g_slist_free_full 2016-10-14 16:57:35 +03:00
John Ernberg
cfd1d2c30a voicecall: Use g_slist_free_full 2016-10-14 16:57:35 +03:00
John Ernberg
cb7c408beb ussd: Use g_slist_free_full 2016-10-14 16:57:35 +03:00
John Ernberg
202d8cf162 stkutil: Use g_slist_free_full 2016-10-14 16:57:35 +03:00
John Ernberg
a15a558af6 smsutil: Use g_slist_free_full 2016-10-14 16:57:35 +03:00
John Ernberg
fd8429465f sms: Use g_slist_free_full 2016-10-14 16:57:35 +03:00
John Ernberg
8db1008790 simutil: Use g_slist_free_full 2016-10-14 16:57:35 +03:00
John Ernberg
3e3b4971da network: Use g_slist_free_full 2016-10-14 16:57:34 +03:00
John Ernberg
7c8245e432 modem: Use g_slist_free_full 2016-10-14 16:57:34 +03:00
John Ernberg
5a06b04e05 handsfree: Use g_slist_free_full 2016-10-14 16:57:34 +03:00
John Ernberg
1c12df9e99 cdma-smsutil: Use g_slist_free_full 2016-10-14 16:57:34 +03:00
John Ernberg
fa3d80cd39 cbs: use g_slist_free_full 2016-10-14 16:57:34 +03:00
John Ernberg
18507364ea smart-messaging: Use g_slist_free_full 2016-10-14 16:57:34 +03:00
John Ernberg
c409ec2940 bluez4: Remove unneeded casts 2016-10-14 16:57:34 +03:00
John Ernberg
bba910a1d6 gatchat: Use g_slist_free_full 2016-10-14 16:57:34 +03:00
John Ernberg
a7867d24e9 stemodem: Use g_slist_free_full 2016-10-14 16:57:34 +03:00
John Ernberg
8909d4928b rilmodem: Use g_slist_free_full 2016-10-14 16:57:34 +03:00
John Ernberg
d9e39a69a5 ifxmodem: Use g_slist_free_full 2016-10-14 16:57:34 +03:00
John Ernberg
0477eeb75f hfpmodem: Use g_slist_free_full 2016-10-14 16:57:34 +03:00
John Ernberg
2ff3613e9b atmodem: use g_slist_free_full 2016-10-14 16:57:34 +03:00
Caiwen Zhang
e5d040f7f9 plugins/ril: Move GPRS atom to 'post_online' state
At gprs atom 'probe' state, max cid query may fail due to rild
status isn't RADIO_STATUS_ON. It causes gprs atom is removed, gprs
feature is inavailable. Move gprs atom creating to 'post_online'
state to make sure rild status is RADIO_STATUS_ON when query max
cid.
2016-10-14 16:57:34 +03:00
John Ernberg
604a3dd22e voicecall: limit g_drivers variable exposure 2016-10-14 16:57:34 +03:00
John Ernberg
5eb923ad28 voicecall: fix CreateMultiparty method introspection
This caused problems with stricter dbus wrappers such as dbus-c++.
2016-10-14 16:57:34 +03:00
Denis Kenzior
94fa037b93 rilmodem: Remove some unneeded whitespace 2016-10-14 16:57:34 +03:00
Denis Kenzior
41135af282 rilmodem: Rename addrs to addr when not plural
addrs variable seems to be used whenever multiple addresses are being
references.  Either as a strv or a compound string separated by a
separator.  In these cases addrs was used for a single address, which
was confusing.
2016-10-14 16:57:34 +03:00
Denis Kenzior
47359a3083 rilmodem: Refactor away some explicit casts 2016-10-14 16:57:34 +03:00
Nishanth V
9c6c354d5a rilmodem: Add IPv6 support in gprs-context 2016-10-14 16:57:34 +03:00
Nishanth V
8ca5fc24ed rilmodem: Add address to protocol type util func 2016-10-14 16:57:34 +03:00
Nishanth V
aecb63423f ril: don't set an ipv4 netmask if not provided
For historical reasons a netmask was always being set, even if one was
not provided.
2016-10-14 16:57:34 +03:00
Nishanth V
f72f84ec0f test: Add list allowed access points script 2016-10-14 16:57:34 +03:00
Nishanth V
e593476d81 plugins: Add allowed apn list
Conflicts:
	ofono/Makefile.am
2016-10-14 16:57:31 +03:00
Nishanth V
1a4f1b0f9f simutil: Add EFACL in elementary file db 2016-10-14 16:52:07 +03:00
Nishanth V
14904ddaeb doc: Add allowed-apns api doc 2016-10-14 16:52:07 +03:00
Caiwen Zhang
5fc9827e5d sim: fix crash when going into state LOCKED_OUT
After input PIN wrong 3 times, sim main state (include spn_watches)
is freed. but the watch id still be kept by other atoms (network and
gprs), when remove the atom, it will try to remove the watch from
spn_watches, ofono daemon will crash.

Conflicts:
	ofono/src/sim.c
2016-10-14 16:52:05 +03:00
Nishanth V
3539b5c9f9 gprs-context: fix set ipv4 netmask for rilmodem 2016-10-14 16:45:55 +03:00
Denis Kenzior
916c1ac904 log: Fix style 2016-10-14 16:45:55 +03:00
Harald Welte
9f659d47b0 log: Don't crash when addr2line output contains no newline 2016-10-14 16:45:55 +03:00
Kuba Pawlak
7d3ec8e9dc unit: fix GCC 6.0 compilation issues
-Werror=unused-const-variable
2016-10-14 16:45:55 +03:00
Kuba Pawlak
d5977f9014 plugins/nokia-gpio: fix glibc 2.23.9+ issues
readdir_r’ is deprecated [-Werror=deprecated-declarations]
2016-10-14 16:45:55 +03:00
Kuba Pawlak
513b922814 drivers/isimodem: fix GCC 6.0 errors
-Werror=misleading-indentation
2016-10-14 16:45:55 +03:00
Denis Kenzior
7f0cc63b3d radio-settings: Fix potential leak
rs->imsi is only freed when rs->settings is true.  So tweak the logic
inside radio_load_settings to only strdup the imsi when settings
creation has succeeded.
2016-10-14 16:45:55 +03:00
Denis Kenzior
9fb47a6382 radio-settings: Fix minor style issues 2016-10-14 16:45:55 +03:00
Anirudh Gargi
ae35e7bff3 radio-settings: Add RAT mode to ofono storage 2016-10-14 16:45:55 +03:00
Alfonso Sanchez-Beato
c7dc8cf262 gprs: Deactivate old contexts on attach
In some cases it is possible that a context is opened after a detach
event has been received, and right before an attach, depending on the
modem. We make sure that those contexts are removed to keep
consistency.
2016-10-14 16:45:55 +03:00
Kuba Pawlak
213df4e7c4 hfp: Handle +CCWA at HFP connection setup
Some phones with an active and waiting call at the time of HFP SLC
establishment, may send call waiting notification before all calls
are synchronized. This will lead to call Id mismatch because call
object is created with assumed Id 1 and not Id assigned by the phone.

In example below waiting call is created with Id 1 but in AT+CLCC
this phone returns active call as call with Id 1, and waiting as 2.

< \r\n+CCWA: "+1234567890",145\r\n
< \r\n+CIEV: 2,1\r\n
drivers/hfpmodem/voicecall.c:ccwa_notify() ccwa_notify: +1234567890 145 0
src/voicecall.c:ofono_voicecall_notify() Got a voicecall event, status: 5, id: 1, number: +1234567890 called_number: , called_name
src/voicecall.c:ofono_voicecall_notify() Did not find a call with id: 1
> AT+CIND?\r
< \r\n+CIND: 1,1,1,4,0,2,0\r\n\r\nOK\r\n
src/network.c:ofono_netreg_status_notify() /hfp/org/bluez/hci0/dev_60_AF_6D_F7_8E_37 status 1 tech -1
> AT+VGS=7\r
< \r\nOK\r\n
> AT+VGM=7\r
< \r\nOK\r\n
> AT+CLCC\r
< \r\n+CLCC: 1,1,0,0,0,"+9876543210",145\r\n
< \r\n+CLCC: 2,1,5,0,0,"+1234567890",145\r\n\r\nOK\r\n
src/voicecall.c:ofono_voicecall_notify() Got a voicecall event, status: 0, id: 1, number: +9876543210 called_number: , called_name
src/voicecall.c:ofono_voicecall_notify() Found call with id: 1
src/voicecall.c:ofono_voicecall_notify() Got a voicecall event, status: 5, id: 2, number: +1234567890 called_number: , called_name
src/voicecall.c:ofono_voicecall_notify() Did not find a call with id: 2
src/voicecall.c:ofono_voicecall_mpty_hint() ids: 0
2016-10-14 16:45:55 +03:00
Denis Kenzior
e78daccea9 AUTHORS: Mention Nishanth's contributions 2016-10-14 16:45:55 +03:00
Samrat Guha Niyogi
4f10d24638 test: Support SoftwareVersionNumber in test-modem 2016-10-14 16:45:55 +03:00
Samrat Guha Niyogi
cfa7ec6dd5 rilmodem: Add support of IMEISV 2016-10-14 16:45:55 +03:00
Denis Kenzior
d18ba4e9a4 modem: Fix style 2016-10-14 16:45:55 +03:00
Samrat Guha Niyogi
8846c58b53 devinfo: Add support of IMEISV 2016-10-14 16:45:55 +03:00
Samrat Guha Niyogi
4f088c85c7 include: Add support for IMEISV in devinfo 2016-10-14 16:45:55 +03:00
Samrat Guha Niyogi
6587a2456a doc: Add SoftwareVersionNumber to Modem interface 2016-10-14 16:45:55 +03:00
Nishanth V
edab9dbf2b test: Add get serving cell information script 2016-10-14 16:45:55 +03:00
Nishanth V
b6cc94bf84 sofia3gr: Add netmon support 2016-10-14 16:45:55 +03:00
Denis Kenzior
4039bed591 rilmodem: Fix minor style issues 2016-10-14 16:45:55 +03:00
Nishanth V
1f56e8350b rilmodem: Add netmon support 2016-10-14 16:45:55 +03:00
Denis Kenzior
34b0d68cdd netmon: Fix minor style issues 2016-10-14 16:45:55 +03:00
Denis Kenzior
ec60fa4eac netmon: Add ofono/netmon.h into ofono.h
Conflicts:
	ofono/src/ofono.h
2016-10-14 16:45:50 +03:00
Nishanth V
a066917c4d netmon: Add serving cell info support
Conflicts:
	ofono/Makefile.am
2016-10-14 16:43:40 +03:00
Nishanth V
da23ddbc15 gril: Added RIL_REQUEST_GET_CELL_INFO_LIST 2016-10-14 16:36:35 +03:00
Denis Kenzior
207f67ab62 include: Fix whitespace issues 2016-10-14 16:36:35 +03:00
Nishanth V
3e3720f416 include: Add netmon changes 2016-10-14 16:36:35 +03:00
Alfonso Sanchez-Beato
985dbf9795 gril: Really use given uid/gid to open ril socket 2016-10-14 16:36:35 +03:00
Denis Kenzior
8b56a11936 AUTHORS: Mention Anirudh's contributions 2016-10-14 16:36:35 +03:00
Denis Kenzior
40aa517183 build: Add recently added test scripts 2016-10-14 16:36:35 +03:00
Anirudh Gargi
6fdf38b74b test: Add sms bearer set and SMSC set scripts 2016-10-14 16:36:35 +03:00
Denis Kenzior
8dc0b46bb3 sofia3gr: Fix style issue 2016-10-14 16:36:35 +03:00
Anirudh Gargi
b772df434b sofia3gr: Enable vendor type in SMS driver 2016-10-14 16:36:34 +03:00
Anirudh Gargi
3726a1a48a rilmodem: Add sms bearer set and bearer query func 2016-10-14 16:36:34 +03:00
Dragos Tatulea
5e309e5d45 gprs: assume attached state when registered on LTE
LTE doesn't really use the concept of an attached state. However,
the oFono API needs it. ConnMan needs it as well.
2016-10-14 16:36:34 +03:00
Denis Kenzior
ea65572935 ubloxmodem: Remove unneeded #include 2016-10-14 16:36:34 +03:00
Dragos Tatulea
83f8e1cbe6 ubloxmodem: support automatic ctx activation
... by imlementing read_settings.
2016-10-14 16:36:34 +03:00
Dragos Tatulea
c97d28cd23 atmodem: gprs: handle automatic context activation
When the event comes, trigger CGCONT? to read the APN for the
activated cid and then call ogono_gprs_cid_activated to handle
the event.
2016-10-14 16:36:34 +03:00
Dragos Tatulea
9279a008ed gprs: implement ofono_gprs_cid_activated
It works by looking for a context with the same APN and tries to use
that. Otherwise it will create it's own.

Then it assigns a gprs context driver and calls it's read_settings if
it exists.
2016-10-14 16:36:34 +03:00
Dragos Tatulea
e9c1603c8b gprs-context.h: add op for reading context config
This will be implemented by a gprs-context driver to support
automatic context activation. The gprs atom will call the driver
to read the ip configuration without activating the context.
2016-10-14 16:36:34 +03:00
Dragos Tatulea
5a8eb818ee idmap: add api for finding a certain id in map 2016-10-14 16:36:34 +03:00
Dragos Tatulea
7ab6bffd07 gprs: pri_set_apn: make reply msg optional
Automatic context activation will set the apn by itself. No
dbus message to reply to.
2016-10-14 16:36:34 +03:00
Dragos Tatulea
86f8a5c1f6 gprs: automatic context configuration notifier
Useful for LTE automatic bearer activation.

This is called from the gprs driver to let the gprs atom know that
a new context has been activated.

Conflicts:
	ofono/include/gprs.h
2016-10-14 16:36:31 +03:00
Dragos Tatulea
f1a87e5f6c gprs: custom cid for assign_context
It's optional though. If 0 a cid is picked up automatically from the
allowed range.
2016-10-14 16:33:19 +03:00
Dragos Tatulea
4dbdf95b12 ubloxmodem: support authentication
If username and password specified, issue an UAUTHREQ
command with the configured authentication method, selected cid
and credentials.
2016-10-14 16:33:19 +03:00
Dragos Tatulea
dab3e86325 ubloxmodem: add Toby L2 gprs context driver
For now the driver works only with bridged mode for 2G/3G.

Once it activates the context it reads the ip, netmask,
gw, dns and sets them in the context settings.
2016-10-14 16:33:19 +03:00
Dragos Tatulea
b62f6c1041 ublox: support more internet contexts
Create multiple gprs-context instances and let the gprs core use
them as it sees fit.

Only for Toby L2.
2016-10-14 16:33:19 +03:00
Dragos Tatulea
f41a998695 ublox: enable ubloxmodem driver when possible
Where possible means Toby L2 in high speed mode.

The bridge mode is set before enabling the modem because the
driver requires this.
2016-10-14 16:33:19 +03:00
Dragos Tatulea
42fa3983ef ublox: give names to model ids
To make it easier to understand the code.
2016-10-14 16:33:19 +03:00
Denis Kenzior
f8a47ae530 ublox: devinfo atom driver has no vendor behavior 2016-10-14 16:33:19 +03:00
Dragos Tatulea
cf202b1568 atmodem: add support for U-Blox TOBY L2 modems
Besides exceptions below, act like normal U-Blox devices.

gprs-context: don't set auth for TOBY L2. U-Blox Toby L2
doesn't support PAP/CHAP APN auth method.

atmodem: TOBY L2 supports only CMER mode 1. Also chaged original
mode variable to ind, which is a more appropriate name.
mode is what is being set first.
2016-10-14 16:33:19 +03:00
Dragos Tatulea
14ebdfe7b9 ublox: use vendor from structure instead of fixed
That's because we need to differentiate between multiple ublox
devices.
2016-10-14 16:33:19 +03:00
Dragos Tatulea
8732a885a3 ublox: allow enabling of TOBY L2 modems
For this we need to:
* Set the vendor family based on model id.
* Not use modem interface for the TOBY L2 family.
2016-10-14 16:33:19 +03:00
Dongsu Park
3f5fa672a5 udevng: Support U-blox TOBY series of devices
Each modem expresses their interfaces with its own interface string,
which is composed of 3 different USB attributes:
"bInterfaceClass/bInterfaceSubClass/bInterfaceProtocol".
While the old models like LISA support only "2/2/1" for modem
interfaces, TOBY-L2 also supports an unique string for NetworkInterface
for each profile.

* low-medium throughput profile : 2/6/0
* fairly backward-compatible profile : 10/0/0
* high throughput profile : 224/1/3

Besides the condition for checking NULL for mdm/aux/net should be relaxed
a little bit.
2016-10-14 16:33:19 +03:00
Denis Kenzior
e358485f37 ril_sofia3gr: Fix warning 2016-10-14 16:33:19 +03:00
Denis Kenzior
e964307ced AUTHORS: Mention Samrat's contributions 2016-10-14 16:33:19 +03:00
Denis Kenzior
d1d69cf667 AUTHORS: Mention Dragos' contributions 2016-10-14 16:33:19 +03:00
Denis Kenzior
bf6210bdbb AUTHORS: Mention Dongsu's contributions 2016-10-14 16:33:19 +03:00
Samrat Guha Niyogi
bcdd5a95c1 ril_sofia3gr: add ussd atom to post_online 2016-10-14 16:33:19 +03:00
Denis Kenzior
fcea7919f9 netmon: Fix enumeration 2016-10-14 16:33:19 +03:00
Denis Kenzior
6fd1c1ef33 include: Add netmon.h
Conflicts:
	ofono/Makefile.am
2016-10-14 16:33:17 +03:00
Denis Kenzior
4d960d898d doc: Add NetworkMonitor API 2016-10-14 16:30:46 +03:00
Denis Kenzior
a9f47b77ce udevng: Move from setup_icera to setup_ublox
As intended by 126b04
2016-10-14 16:30:46 +03:00
Dragos Tatulea
fb81c3571b atmodem: ublox: EPS now supported by newer ublox
Based on UBX-13002752 R33
2016-10-14 16:30:46 +03:00
Dragos Tatulea
7809498588 atmodem: add vendor enumeration for ublox toby
Required to differentiate between the old LISA family
of supported devices and future TOBY L2 devices.
2016-10-14 16:30:46 +03:00
Dragos Tatulea
4d05522b2a plugins/udevng: ublox: set model string
Necessary for supporting the ublox TOBY L2 modem.
2016-10-14 16:30:46 +03:00
Dongsu Park
b6b0306b39 plugins/udevng: support the U-Blox TOBY-L2 series
The newest generation of U-Blox TOBY-L2 series can be detected with
VID 0x1546 (the same as before), and one of the following PIDs:

* "0x1146" : high throughput profile
* "0x1141" : fairly back-compatible profile
* "0x1143" : low/medium throughput profile

This patch adds detection for high throughput mode.
2016-10-14 16:30:46 +03:00
Denis Kenzior
5c938a5b64 test: Add register-operator 2016-10-14 16:30:46 +03:00
Denis Kenzior
b04d30ff3e test: Add register-auto
Conflicts:
	ofono/Makefile.am
2016-10-14 16:30:44 +03:00
Denis Kenzior
4bdc8ac62c gitignore: Add rilmodem-cb and rilmodem-sms 2016-10-14 16:24:07 +03:00
Kuba Pawlak
fa20be318d hfpmodem: Handle repeated held call indicator
An issue with iPhone 5C iOS 9.2 triggers desynchronization in call
states. When an active call is put on hold and another call arrives,
it is in WAITING state. It should be possible to answer it by issuing
AT+CHLD=2 but the phone changes its state to INCOMING so ATA should be
used. This change is advertised by sending callheld:2 event, but it is
not handled. This event can be used to trigger CLCC poll to synchronize
call states.

+CIEV: 3,1   <- first call arrives
AT+CLCC
+CLCC: 1,1,4,0,0,"01234567890",129
OK
RING
+CLIP: "01234567890",129
ATA
OK
+CIEV: 2,1
+CIEV: 3,0.
AT+CHLD=2.$  <- first call is put on hold
OK
+CIEV: 7,2   <- notification confirming that call #1 is on hold
+CCWA: "09876543210",129,1     <- second call arrives
+CIEV: 7,2
+CIEV: 3,1
AT+CLCC
+CLCC: 1,1,1,0,0,"01234567890",129
+CLCC: 2,1,5,0,0,"09876543210",129 <- new call is still in WAITING state
OK
+CIEV: 7,2 <- phone iternally promotes WAITING call to INCOMING
AT+CHLD=2  <- there is no WAITING call anymore, ATA should be used
+CME ERROR:3
2016-10-14 16:24:07 +03:00
Denis Kenzior
3598f4edab gatchat: Add support for shutting down the server
By sending SIGUSR1 we can initiate a soft server-shutdown.
2016-10-14 16:24:07 +03:00
Denis Kenzior
0524862743 ril_sofia3gr: Add radio_settings atom 2016-10-14 16:23:57 +03:00
Denis Kenzior
d2cfc16201 AUTHORS: Mention John's contributions 2016-10-14 16:23:48 +03:00
Tony Espy
fd874f3a4c build: add support for upower plugin 2016-10-14 16:23:36 +03:00
Tony Espy
0a039db7da plugins: add upower battery monitor for bluetooth 2016-10-14 16:23:36 +03:00
Denis Kenzior
0e6ce9a38e rilmodem: Initialize ofono_error correctly 2016-10-14 16:23:36 +03:00
Tony Espy
3cad68861c build: untangle ATMODEM and BLUETOOTH conditionals 2016-10-14 16:23:36 +03:00
Denis Kenzior
70d9366499 HACKING: Update instructions with email address 2016-10-14 16:23:36 +03:00
Denis Kenzior
6c17d2b79c ril: Use g_ril_new_with_ucred 2016-10-14 16:23:36 +03:00
Denis Kenzior
811b478903 gril: Add g_ril_new_with_ucred 2016-10-14 16:23:36 +03:00
Denis Kenzior
6fcc2a1f68 gril: Remove unneeded defines 2016-10-14 16:23:36 +03:00
Denis Kenzior
792c4674c2 plugins: Add sofia3GR ril driver 2016-10-14 16:23:36 +03:00
Denis Kenzior
e9df792102 build: Fix building without atmodem support 2016-10-14 16:23:36 +03:00
Denis Kenzior
eb92f42c7d stktest: Remove usage of decode_at_error
Otherwise the build fails when building without atmodem support
2016-10-14 16:23:36 +03:00
Tony Espy
bcafdc8d70 build: add support for new test-rilmodem-cb
Conflicts:
	ofono/Makefile.am
2016-10-14 16:23:23 +03:00
Tony Espy
5aa8f72aaa rilmodem: fix call_barring_query_cb
The return value from a RIL_REQUEST_GET_FACILITY_LOCK
is the TS 27.007 service class bit vector of services
for the specified barring facility.  The value canf be
zero, which indicates "disabled for all".
2016-10-14 16:21:52 +03:00
Tony Espy
704a3ae354 unit: add new test-rilmodem-cb 2016-10-14 16:21:52 +03:00
Denis Kenzior
a4f91f2d80 ril: Get rid of ril_gprs_context_data 2016-10-14 16:21:52 +03:00
Denis Kenzior
e655837ccb rilmodem: Get rid of ril_gprs_context_data 2016-10-14 16:21:52 +03:00
Denis Kenzior
800ad72129 ril: Don't use ril_sim_data 2016-10-14 16:21:41 +03:00
Denis Kenzior
e6cae75c40 rilmodem: Get rid of ril_sim_data 2016-10-14 16:21:41 +03:00
Denis Kenzior
d655aec432 sim: Silence warning on 32-bit 2016-10-14 16:21:41 +03:00
Denis Kenzior
cd2d6a28aa gril: Use unsigned int instead of gsize
Sizeof gsize changes depending on 32/64 bit system.  However, in reality
it is always 4 bytes.
2016-10-14 16:21:41 +03:00
Denis Kenzior
8507197fa6 sim: Tweak debug statement 2016-10-14 16:21:41 +03:00
Denis Kenzior
ee6b3385db sim: Add additional DBG statements 2016-10-14 16:21:41 +03:00
Tony Espy
24b6aeab5c rilmodem: fix sim_status_cb debug logging
During the re-factoring of rilmodem's sim atom
messaging code, the sim_status_cb function's
RIL tracing code was converted to DBG calls.
This change adds the same prefix to DBG/trace
calls when a single message's parameters span
more than one DBG call. This makes it easier
to filter out trace messages when looking at a
log file.
2016-10-14 16:21:41 +03:00
Tony Espy
5436c2beea unit: update test-rilmodem-sms set_sca test case
Update test-rilmodem-sms set_sca test case to take
into account additional quotes used for sending
a SET_SMSC_ADDRESS request.
2016-10-14 16:21:41 +03:00
Tony Espy
87d947fe48 rilmodem: restore SET_SMSC_ADDRESS number format
Restore quoting of SMSC number string, as it's
required by at least one rild implementation (mako).
2016-10-14 16:21:41 +03:00
Denis Kenzior
af45298bc7 rilmodem: Remove unneeded include 2016-10-14 16:21:41 +03:00
Denis Kenzior
cdb32c9139 gril: Remove grilunsol.[ch] 2016-10-14 16:21:41 +03:00
Denis Kenzior
85a9daa5f4 rilmodem: Don't include grilunsol.h 2016-10-14 16:21:41 +03:00
Denis Kenzior
17a4fd7b78 ril: Don't include grilunsol.h 2016-10-14 16:21:41 +03:00
Denis Kenzior
d42b983dee gril: Remove g_ril_unsol_parse_data_call_list 2016-10-14 16:21:41 +03:00
Denis Kenzior
33b14a3326 rilmodem: Implement ril_setup_data_call_cb inline 2016-10-14 16:21:41 +03:00
Denis Kenzior
09ac10c3ac rilmodem: Implement get_active_data_calls_cb inline 2016-10-14 16:21:41 +03:00
Denis Kenzior
f47fe40799 gril: Remove unused str_array functions 2016-10-14 16:21:41 +03:00
Denis Kenzior
ef0532222f gril: Remove unused ril_radio_tech_to_string 2016-10-14 16:21:41 +03:00
Denis Kenzior
edf7608da8 gril: Remove unused ril_pinstate_to_string 2016-10-14 16:21:41 +03:00
Denis Kenzior
1bd019aec7 gril: Remove unused ril_cardstate_to_string 2016-10-14 16:21:41 +03:00
Denis Kenzior
57ea46e0d7 gril: Remove unused ril_authtype_to_string 2016-10-14 16:21:41 +03:00
Denis Kenzior
90c4dfe1e5 gril: Remove unused ril_apptype_to_string 2016-10-14 16:21:41 +03:00
Denis Kenzior
4112433e86 gril: Remove unused ril_appstate_to_string 2016-10-14 16:21:41 +03:00
Denis Kenzior
97830c757f gril: Remove unused ril_ofono_protocol_to_ril_string 2016-10-14 16:21:41 +03:00
Denis Kenzior
2dcfd64ff4 rilmodem: Remove drivers/rilmodem/gprs.h 2016-10-14 16:21:41 +03:00
Denis Kenzior
cba91bff8b rilmodem: Don't expose private structures 2016-10-14 16:21:41 +03:00
Denis Kenzior
7bf1f707ff rilmodem: Get rid of unnecessary exports 2016-10-14 16:21:24 +03:00
Denis Kenzior
aa6eed4eeb rilmodem: Get rid of ril_gprs_driver_data 2016-10-14 16:21:24 +03:00
Denis Kenzior
18e6d86edd ril: Get rid of gprs_driver_data 2016-10-14 16:21:24 +03:00
Denis Kenzior
e40d9e80c7 rilmodem: Get rid of useless member variable 2016-10-14 16:21:24 +03:00
Denis Kenzior
4176a82a0b rilmodem: Remove data reg state query retry logic
This is no longer needed as the query for max_cid is done in a different
logic flow.
2016-10-14 16:21:23 +03:00
Denis Kenzior
447d0af56c gril: Remove grilreply.[ch] 2016-10-14 16:21:23 +03:00
Denis Kenzior
284c7dfc48 rilmodem: Don't include grilreply.h 2016-10-14 16:21:23 +03:00
Denis Kenzior
a1a6ff7976 ril: Don't include grilreply.h 2016-10-14 16:21:23 +03:00
Denis Kenzior
e2e4b7c868 rilmodem: use g_new0 instead of g_try_new0 2016-10-14 16:21:23 +03:00
Denis Kenzior
5103af4321 gril: Remove g_ril_reply_parse_get_calls 2016-10-14 16:21:23 +03:00
Denis Kenzior
b3a10881e7 rilmodem: Implement clcc_poll_cb inline 2016-10-14 16:21:23 +03:00
Denis Kenzior
cbc9ce47e0 gril: Remove g_ril_reply_parse_retries 2016-10-14 16:21:23 +03:00
Denis Kenzior
cf059171d7 rilmodem: Implement ril_pin_change_state_cb inline 2016-10-14 16:21:23 +03:00
Denis Kenzior
ddabae7a54 gril: Remove g_ril_reply_oem_hook_raw 2016-10-14 16:21:23 +03:00
Denis Kenzior
aabfd23aed rilmodem: Implement inf_pin_retries_cb inline 2016-10-14 16:21:23 +03:00
Denis Kenzior
f7a1089bd6 gril: Remove g_ril_reply_oem_hook_strings 2016-10-14 16:21:23 +03:00
Denis Kenzior
1ba9668f55 rilmodem: Implement mtk_pin_retries_cb inline 2016-10-14 16:21:23 +03:00
Denis Kenzior
f6adb2a47e gril: Remove grilrequest.[ch] 2016-10-14 16:21:23 +03:00
Denis Kenzior
1254716006 rilmodem: Don't include grilrequest.h 2016-10-14 16:21:23 +03:00
Denis Kenzior
1da578f9af ril: Remove grilrequest.h 2016-10-14 16:21:23 +03:00
Denis Kenzior
863b91f79e gril: Remove g_ril_request_oem_hook_strings 2016-10-14 16:21:23 +03:00
Denis Kenzior
5c4cd29fc2 rilmodem: Inline g_ril_request_oem_hook_strings 2016-10-14 16:21:23 +03:00
Denis Kenzior
78ea7d9946 gril: Remove g_ril_request_oem_hook_raw 2016-10-14 16:21:23 +03:00
Denis Kenzior
e684560e16 rilmodem: inline request_oem_hook_raw 2016-10-14 16:21:23 +03:00
Denis Kenzior
0af7fd0c2c gril: Remove g_ril_reply_parse_data_reg_state 2016-10-14 16:21:23 +03:00
Denis Kenzior
9b20f4c904 rilmodem: Refactor ril_data_reg_cb 2016-10-14 16:21:23 +03:00
Denis Kenzior
1c217547fd gril: Remove g_ril_reply_parse_voice_reg_state 2016-10-14 16:21:23 +03:00
Denis Kenzior
1939a251a0 rilmodem: Implement reg_cb inline 2016-10-14 16:21:23 +03:00
Denis Kenzior
deaee2b27d rilmodem: Add ril_util_registration_state_to_status 2016-10-14 16:21:23 +03:00
Denis Kenzior
28d59901c2 gril: Add parcel_r_strv 2016-10-14 16:21:23 +03:00
Denis Kenzior
d6ffc2dae7 gril: Remove g_ril_request_setup_data_call 2016-10-14 16:21:23 +03:00
Denis Kenzior
59d80cdaa2 rilmodem: Implement activate_primary inline 2016-10-14 16:21:23 +03:00
Denis Kenzior
e680c7a3dc rilmodem: Add ril_util_gprs_proto_to_ril_string 2016-10-14 16:21:23 +03:00
Denis Kenzior
8fb813ab94 gril: Remove g_ril_reply_parse_sim_status 2016-10-14 16:21:23 +03:00
Denis Kenzior
ca507cbfaf rilmodem: Refactor get_sim_status reply parsing 2016-10-14 16:21:23 +03:00
Denis Kenzior
d40079d0b5 gril: Add parcel skip string 2016-10-14 16:21:23 +03:00
Denis Kenzior
9579ce72a0 gril: Remove g_ril_reply_parse_sim_io & related 2016-10-14 16:21:23 +03:00
Denis Kenzior
59880f886c rilmodem: Implement sim io parser inline 2016-10-14 16:21:23 +03:00
Denis Kenzior
3cb3b96104 rilmodem: Remove unused ril_util_sim_state_query 2016-10-14 16:21:01 +03:00
Tony Espy
4a384a95a0 rilmodem: fix set_call_barring reply trace (mako)
This change restores the trace output for a reply to a
REQUEST_SET_FACILITY_LOCK used by the set function.
2016-10-14 16:21:01 +03:00
Tony Espy
c69b01677f unit: add new test-rilmodem-sms test cases
Add new test-rilmodem-sms test cases for the remaining
untested atom functions, including two tests for incoming
SMS unsolicited responses. Also updated test-rilmodem-cs
due to rilmodem-test-server changes.
2016-10-14 16:21:01 +03:00
Tony Espy
fd358758ce unit: add write support to rilmodem-test-server
This change adds write support to the rilmodem-test-server
in order to support testing receipt of unsolicted RIL
responses.
2016-10-14 16:21:01 +03:00
Denis Kenzior
b2d55c3bc4 rilmodem: Remove unused ril_util_call_compare_by_status 2016-10-14 16:21:01 +03:00
Denis Kenzior
d0c9970d15 rilmodem: Remove unused compare_by_phone_number 2016-10-14 16:21:01 +03:00
Denis Kenzior
daccbdbeaf rilmodem: Remove unused ril_util_call_compare 2016-10-14 16:21:01 +03:00
Denis Kenzior
71c032167d rilmodem: Remove unused ril_util_call_compare_by_id 2016-10-14 16:21:01 +03:00
Denis Kenzior
82ed6eeba5 gril: Remove g_ril_request_set_net_select_manual 2016-10-14 16:21:01 +03:00
Denis Kenzior
51cb5c773a rilmodem: Implement ril_register_manual inline 2016-10-14 16:21:01 +03:00
Denis Kenzior
da3fd754a7 gril: Remove g_ril_request_deactivate_data_call 2016-10-14 16:21:01 +03:00
Denis Kenzior
7b70463912 rilmodem: Use ril_util_build_deactivate_data_call 2016-10-14 16:21:01 +03:00
Denis Kenzior
3107fa0ce4 rilmodem: Add ril_util_build_deactivate_data_call 2016-10-14 16:21:01 +03:00
Denis Kenzior
ade915136b gril: Remove g_ril_request_sim_write_record 2016-10-14 16:21:01 +03:00
Denis Kenzior
4ad21b004a rilmodem: implement update_record inline 2016-10-14 16:21:01 +03:00
Denis Kenzior
9ef2e5353c gril: Remove g_ril_request_sim_write_binary 2016-10-14 16:21:01 +03:00
Denis Kenzior
1ca3716e8f rilmodem: Implement ril_sim_update_binary inline 2016-10-14 16:21:01 +03:00
Denis Kenzior
3df6a64280 gril: Remove g_ril_request_sim_read_record 2016-10-14 16:21:01 +03:00
Denis Kenzior
476af72e35 rilmodem: Implement ril_sim_read_record inline 2016-10-14 16:21:01 +03:00
Denis Kenzior
b8c7bcc996 gril: Remove g_ril_request_sim_read_binary 2016-10-14 16:21:01 +03:00
Denis Kenzior
0418a7db78 rilmodem: Implement ril_sim_read_binary inline 2016-10-14 16:21:01 +03:00
Denis Kenzior
1ab5d2e278 gril: Remove g_ril_request_sim_read_info 2016-10-14 16:21:01 +03:00
Denis Kenzior
4155f4ad82 rilmodem: Implement ril_sim_read_info inline 2016-10-14 16:21:01 +03:00
Tony Espy
4b5ebcbefd build: update for test-rilmodem-cs changes
Conflicts:
	ofono/Makefile.am
2016-10-14 16:20:59 +03:00
Tony Espy
1298be1adb unit: re-factor test-rilmodem-cs server logic
Use the new rilmodem-test-server functions.
2016-10-14 16:17:51 +03:00
Tony Espy
52a4e9b5e6 build: add support for test-rilmodem-sms
Conflicts:
	ofono/Makefile.am
2016-10-14 16:17:48 +03:00
Tony Espy
23373e6ce7 unit: add new test-rilmodem-sms 2016-10-14 16:11:14 +03:00
Tony Espy
ed23172c8b plugins: rm unneeded exits/sleeps from ril plugin 2016-10-14 16:11:14 +03:00
Tony Espy
1c3fc7dedc ril: remove unecessary sleep from ril plugin 2016-10-14 16:11:14 +03:00
Denis Kenzior
8f4101d57e gril: Remove g_ril_unsol_parse_radio_state_changed 2016-10-14 16:11:14 +03:00
Denis Kenzior
2cda8bc793 ril: Implement radio state changed parsing inline 2016-10-14 16:11:14 +03:00
Petr Vorel
51d004c32c gobi: Add missing _GNU_SOURCE
as we're using O_CLOEXEC
2016-10-14 16:11:14 +03:00
Denis Kenzior
74e7e2444f rilmodem: Simplify ril_gprs_set_attached 2016-10-14 16:11:14 +03:00
Denis Kenzior
5e6a565274 gril: Remove g_ril_reply_parse_operator 2016-10-14 16:10:52 +03:00
Denis Kenzior
f2c7812932 rilmodem: Implement ril_cops_cb inline 2016-10-14 16:10:52 +03:00
Denis Kenzior
8ce00e707b gril: Remove g_ril_reply_parse_avail_ops 2016-10-14 16:10:52 +03:00
Denis Kenzior
6aaae6bc6a rilmodem: Implement ril_cops_list_cb inline 2016-10-14 16:10:52 +03:00
Denis Kenzior
d34c5fd54d gril: Remove g_ril_unsol_parse_nitz 2016-10-14 16:10:52 +03:00
Denis Kenzior
8ed185e32d rilmodem: Implement ril_nitz_notify inline 2016-10-14 16:10:52 +03:00
Denis Kenzior
d789992c87 gril: Remove g_ril_unsol_parse_signal_strength 2016-10-14 16:10:52 +03:00
Denis Kenzior
d3f266372b rilmodem: Inline signal strength parsing & calc 2016-10-14 16:10:52 +03:00
Alfonso Sanchez-Beato
8e036c29fc gitignore: Ignore rilmodem-cs test binary 2016-10-14 16:10:46 +03:00
Denis Kenzior
8950228a9f gril: Remove g_ril_reply_parse_call_fail_cause 2016-10-14 16:09:58 +03:00
Denis Kenzior
54cfafa20d rilmodem: Implement lastcause_cb inline 2016-10-14 16:09:58 +03:00
Denis Kenzior
17fdc3f451 gril: Remove g_ril_unsol_parse_supp_svc_notif 2016-10-14 16:09:57 +03:00
Denis Kenzior
8fe0b753e8 rilmodem: Implement ril_ss_notify inline 2016-10-14 16:09:57 +03:00
Denis Kenzior
06e61e1d8b gril: Remove g_ril_request_dial 2016-10-14 16:09:57 +03:00
Denis Kenzior
4cbc64e4e9 rilmodem: Implement dial inline 2016-10-14 16:09:57 +03:00
Denis Kenzior
7d90b6e86c gril: Remove g_ril_request_hangup 2016-10-14 16:09:57 +03:00
Denis Kenzior
01fcc3df4b rilmodem: Implement hangups inline 2016-10-14 16:09:57 +03:00
Denis Kenzior
52a0680c31 gril: Remove g_ril_request_dtmf 2016-10-14 16:09:57 +03:00
Denis Kenzior
809cd31f3f rilmodem: Implement send_one_dtmf inline 2016-10-14 16:09:57 +03:00
Denis Kenzior
c05b8864b0 TODO: Add DTMF batch hint task 2016-10-14 16:09:57 +03:00
Denis Kenzior
f12701af82 gril: Remove g_ril_request_separate_conn 2016-10-14 16:09:57 +03:00
Denis Kenzior
f6f27acb04 rilmodem: Implement ril_private_chat inline 2016-10-14 16:09:57 +03:00
Denis Kenzior
5f45c9487b gril: Remove g_ril_request_set_supp_svc_notif 2016-10-14 16:09:57 +03:00
Denis Kenzior
fc286131db rilmodem: Implement enable_supp_svc inline 2016-10-14 16:09:57 +03:00
Denis Kenzior
e037227dc1 rilmodem: Get rid of ril_voicecall_driver_data 2016-10-14 16:09:57 +03:00
Denis Kenzior
7cd35aaac3 voicecall: Remove redundant comment 2016-10-14 16:09:57 +03:00
Denis Kenzior
0c52074896 ril: Don't use ril_voicecall_driver_data 2016-10-14 16:09:57 +03:00
Denis Kenzior
c351edd7a5 rilmodem: Remove auto-answering logic
This was only used for testing at the factory for a specific product.
Does not belong in the driver code.
2016-10-14 16:09:57 +03:00
Denis Kenzior
80ead5dedb gril: Remove g_ril_request_pin_change_state 2016-10-14 16:09:57 +03:00
Denis Kenzior
0684eeffc0 rilmodem: Implement ril_pin_change_state inline 2016-10-14 16:09:57 +03:00
Denis Kenzior
918706835b gril: Remove g_ril_request_change_passwd 2016-10-14 16:09:57 +03:00
Denis Kenzior
67b37c9cd5 rilmodem: Implement ril_change_passwd inline 2016-10-14 16:09:57 +03:00
Denis Kenzior
9bcb302884 gril: Remove g_ril_request_pin_send_puk 2016-10-14 16:09:57 +03:00
Denis Kenzior
80f7393415 rilmodem: Implement ril_pin_send_puk inline 2016-10-14 16:09:57 +03:00
Denis Kenzior
58759583fa gril: Remove g_ril_request_pin_send 2016-10-14 16:09:57 +03:00
Denis Kenzior
63b3dc2be9 rilmodem: Implement ril_pin_send inline 2016-10-14 16:09:57 +03:00
Denis Kenzior
57a242851a rilmodem: Fix up headers in sms 2016-10-14 16:09:57 +03:00
Denis Kenzior
b5f01aa8d2 gril: Remove g_ril_reply_parse_get_smsc_address 2016-10-14 16:09:57 +03:00
Denis Kenzior
19563292d9 rilmodem: Implement ril_csca_query_cb inline 2016-10-14 16:09:57 +03:00
Denis Kenzior
6780b25091 gril: Remove g_ril_reply_parse_sms_response 2016-10-14 16:09:57 +03:00
Denis Kenzior
7c9242398e rilmodem: Implement ril_submit_sms_cb inline 2016-10-14 16:09:57 +03:00
Denis Kenzior
e244554917 gril: Remove g_ril_request_sms_acknowledge 2016-10-14 16:09:57 +03:00
Denis Kenzior
60782673dc rilmodem: Implement ril_ack_delivery inline 2016-10-14 16:09:57 +03:00
Denis Kenzior
8442cc21cd gril: Remove g_ril_request_sms_cmgs 2016-10-14 16:09:57 +03:00
Denis Kenzior
1d6082005e rilmodem: Implement ril_cmgs inline 2016-10-14 16:09:57 +03:00
Denis Kenzior
2a45912752 gril: Remove g_ril_request_set_smsc_address 2016-10-14 16:09:57 +03:00
Denis Kenzior
bef4e531b7 rilmodem: Implement ril_csca_set inline 2016-10-14 16:09:57 +03:00
Denis Kenzior
cc2781ee50 gril: Remove g_ril_unsol_parse_new_sms & related 2016-10-14 16:09:57 +03:00
Denis Kenzior
340b66025b rilmodem: Implement ril_sms_notify inline 2016-10-14 16:09:57 +03:00
Denis Kenzior
9879fd990c rilmodem: Remove unneeded code 2016-10-14 16:09:57 +03:00
Denis Kenzior
74db6eb392 rilmodem: Remove comments that state the obvious 2016-10-14 16:09:57 +03:00
Denis Kenzior
771d338001 gril: Remove radio-setting specific constants 2016-10-14 16:09:57 +03:00
Denis Kenzior
6808dd688e rilmodem: Move constants from gril 2016-10-14 16:09:57 +03:00
Denis Kenzior
2d46bbac4d gril: Remove g_ril_request_set_preferred_network_type 2016-10-14 16:09:57 +03:00
Denis Kenzior
442b427a19 rilmodem: Implement ril_set_rat_mode inline 2016-10-14 16:09:57 +03:00
Denis Kenzior
bebe9d8d8a gril: Remove g_ril_reply_parse_get_preferred_network_type 2016-10-14 16:09:57 +03:00
Denis Kenzior
1b21edb1f5 rilmodem: Implement ril_rat_mode_cb inline 2016-10-14 16:09:57 +03:00
Denis Kenzior
52ee74f0af gril: Remove g_ril_request_screen_state 2016-10-14 16:09:57 +03:00
Denis Kenzior
296dd76ff7 rilmodem: Implement ril_set_fast_dormancy inline 2016-10-14 16:09:57 +03:00
Denis Kenzior
0e68c13837 rilmodem: Get rid of pointless g_idle_add 2016-10-14 16:09:57 +03:00
Denis Kenzior
d332624f5c rilmodem: Get rid of ril_radio_settings_driver_data 2016-10-14 16:09:57 +03:00
Denis Kenzior
fbee20e850 ril: Pass GRil object to radio_settings
Instead of ril_radio_settings_driver_data
2016-10-14 16:09:57 +03:00
Denis Kenzior
eb52bc247a rilmodem: Get rid of radio-settings.h 2016-10-14 16:03:39 +03:00
Denis Kenzior
0741acca48 build: Make distcheck pass again 2016-10-14 16:03:39 +03:00
Denis Kenzior
70d2d70623 gril: Fix distcheck error 2016-10-14 16:03:39 +03:00
Denis Kenzior
baca4c0371 rilmodem: Get rid of g_try_new0 2016-10-14 16:03:39 +03:00
Denis Kenzior
aa5e04cbca build: Tweak gril_sources 2016-10-14 16:03:39 +03:00
Tony Espy
f1cc9990b3 build: add support for rilmodem-cs test
Conflicts:
	ofono/Makefile.am
2016-10-14 16:03:37 +03:00
Tony Espy
6bd0264a22 unit: add new test rilmodem-cs
This commit adds a new style of build-time/unit test to
rilmodem.  These tests setup a dummy server socket and
attach a gril instance to it.  This allows rilmodem
call-settings atom functions to be tested directly,
validating request parcels received by the server-side,
and callbacks that happen in response to canned responses
sent by the server-side.
2016-10-14 16:00:33 +03:00
Denis Kenzior
19166a33ef gril: Remove g_ril_request_send_ussd 2016-10-14 16:00:26 +03:00
Denis Kenzior
eb6128ccb6 rilmodem: Make ril_ussd_request inline 2016-10-14 16:00:26 +03:00
Denis Kenzior
46e5909e17 rilmodem: Rework ril_ussd_request 2016-10-14 16:00:26 +03:00
Denis Kenzior
b5652aaf09 rilmodem: Rework ril_ussd_cancel 2016-10-14 16:00:26 +03:00
Denis Kenzior
aa4b7c2a89 gril: Remove g_ril_unsol_parse_ussd and related 2016-10-14 16:00:26 +03:00
Denis Kenzior
1b274a6470 rilmodem: Implement ril_ussd_notify inline 2016-10-14 16:00:26 +03:00
Denis Kenzior
cc6a53b191 rilmodem: Inline query_serial and query_revision
query_serial was supposed to use parse_imei functionality, but called
baseband_version instead.  Rework both these to use inline parsers.
2016-10-14 16:00:26 +03:00
Denis Kenzior
1b5b1b545b gril: Remove g_ril_reply_parse_get_imei 2016-10-14 16:00:26 +03:00
Denis Kenzior
4389fffb72 gril: Remove g_ril_reply_parse_baseband_version 2016-10-14 16:00:26 +03:00
Denis Kenzior
95ca9ae64d rilmodem: Rework devinfo driver
Remove comments that state the obvious
Remove pointless allocations / frees
2016-10-14 16:00:26 +03:00
Denis Kenzior
71aded607f rilmodem: Rework header order in call-volume 2016-10-14 16:00:26 +03:00
Denis Kenzior
d209f372d4 gril: Remove g_ril_reply_parse_get_mute 2016-10-14 16:00:26 +03:00
Denis Kenzior
aa16342fc1 rilmodem: Implement probe_mute_cb inline 2016-10-14 16:00:26 +03:00
Denis Kenzior
2a7a6f7f0c gril: Remove g_ril_request_set_mute 2016-10-14 16:00:26 +03:00
Denis Kenzior
08a320ad90 rilmodem: Implement ril_call_volume_mute inline 2016-10-14 16:00:26 +03:00
Denis Kenzior
ff1dffebe4 rilmodem: Rework header order in call-settings 2016-10-14 16:00:26 +03:00
Denis Kenzior
fac809eac9 rilmodem: Rework header order in call-forwarding 2016-10-14 16:00:26 +03:00
Denis Kenzior
6420640395 rilmodem: Rework header order in call-barring 2016-10-14 16:00:26 +03:00
Denis Kenzior
400cfed044 gril: Remove g_ril_reply_parse_set_facility_lock 2016-10-14 16:00:26 +03:00
Denis Kenzior
eef25504f9 rilmodem: Implement ril_call_barring_set_cb inline 2016-10-14 16:00:26 +03:00
Denis Kenzior
4db63e87f7 gril: Remove g_ril_reply_parse_query_facility_lock 2016-10-14 16:00:26 +03:00
Denis Kenzior
440da3c009 rilmodem: Implement ril_call_barring_query_cb inline 2016-10-14 16:00:26 +03:00
Denis Kenzior
d3e2ce9c9b gril: Remove g_ril_request_change_barring_password 2016-10-14 16:00:26 +03:00
Denis Kenzior
93cd410a7b rilmodem: Make ril_call_barring_set_passwd inline 2016-10-14 16:00:26 +03:00
Denis Kenzior
e0fbec976b gril: Remove g_ril_request_set_facility_lock 2016-10-14 16:00:25 +03:00
Denis Kenzior
f34d2f9dcf rilmodem: Implement ril_call_barring_set inline 2016-10-14 16:00:25 +03:00
Denis Kenzior
361c552898 gril: Remove g_ril_request_query_facility_lock 2016-10-14 16:00:25 +03:00
Denis Kenzior
d675c3362f rilmodem: Implement ril_call_barring_query inline 2016-10-14 16:00:25 +03:00
Denis Kenzior
9c014fba03 gril: Remove g_ril_request_power 2016-10-14 16:00:25 +03:00
Denis Kenzior
89a76af30f ril: Implement power on/off inline 2016-10-14 16:00:25 +03:00
Denis Kenzior
120f200ba1 gril: Remove g_ril_reply_parse_query_call_fwd 2016-10-14 16:00:25 +03:00
Denis Kenzior
f2a8ccf079 rilmodem: Implement g_ril_request_call_fwd inline 2016-10-14 16:00:25 +03:00
Denis Kenzior
dec2dcd735 gril: Remove g_ril_request_call_fwd and related 2016-10-14 16:00:25 +03:00
Denis Kenzior
29a1f8d9ed rilmodem: Rework call-forwarding requests 2016-10-14 16:00:25 +03:00
Denis Kenzior
3b7ef48976 gril: Remove g_ril_reply_parse_imsi 2016-10-14 16:00:25 +03:00
Denis Kenzior
b9ea2e0924 rilmodem: Implement ril_imsi_cb inline 2016-10-14 16:00:25 +03:00
Denis Kenzior
0845da6a2e gril: Remove g_ril_reply_parse_get_clir & related 2016-10-14 16:00:25 +03:00
Denis Kenzior
300a11c2e3 rilmodem: Implement ril_clir_query_cb inline 2016-10-14 16:00:25 +03:00
Denis Kenzior
c5cc1ff7c8 gril: Remove g_ril_reply_parse_query_clip 2016-10-14 16:00:25 +03:00
Denis Kenzior
cdaa2fedab rilmodem: Implement ril_clip_query_cb inline 2016-10-14 16:00:25 +03:00
Denis Kenzior
2684fbf24d gril: Remove g_ril_reply_parse_query_call_waiting 2016-10-14 16:00:25 +03:00
Denis Kenzior
93300ee95e rilmodem: Implement ril_cw_query_cb inline 2016-10-14 16:00:25 +03:00
Denis Kenzior
8c175ab282 gril: Remove g_ril_request_set_clir 2016-10-14 16:00:25 +03:00
Denis Kenzior
24b9943dc1 rilmodem: Implement ril_clir_set inline 2016-10-14 16:00:25 +03:00
Denis Kenzior
3e711843cb gril: g_ril_request_query_call_waiting 2016-10-14 16:00:25 +03:00
Denis Kenzior
ead815513d rilmodem: Implement ril_cw_query inline 2016-10-14 16:00:25 +03:00
Denis Kenzior
dd78ee5fcb gril: Remove g_ril_request_set_call_waiting 2016-10-14 16:00:25 +03:00
Denis Kenzior
e61bfe0f38 rilmodem: Implement ril_cw_set inline 2016-10-14 16:00:25 +03:00
Alfonso Sanchez-Beato
f22a531051 gril: Fix access to notify callbacks
Entries to the table of notification callbacks can be added by the
callbacks while being called. This caused a glib error as gril was
using an iterator to the hash table while the table was being modified.
Fixed by avoiding the unnecesary loop.
2016-10-14 16:00:25 +03:00
Simon Fels
c2a1c60b92 hfp_ag_bluez5: use codec negotiation 2016-10-14 16:00:25 +03:00
Simon Fels
82bf1057bb emulator: add codec negotiation support 2016-10-14 16:00:25 +03:00
Simon Fels
1a25661400 hfp_ag_bluez5: Add initial handsfree audio driver 2016-10-14 16:00:25 +03:00
Alfonso Sanchez-Beato
466a65f2da gril: Remove asserts 2016-10-14 16:00:25 +03:00
Alfonso Sanchez-Beato
a672583053 rildev: Do not create modems if no env var set
Do not create rilmodem instances if the environment variable
OFONO_RIL_DEVICE is not set.
2016-10-14 16:00:25 +03:00
Denis Kenzior
f47e720628 gril: Remove g_ril_request_read_imsi 2016-10-14 16:00:25 +03:00
Denis Kenzior
c0433efc12 rilmodem: Move get_imsi implementation to rilmodem 2016-10-14 16:00:25 +03:00
Denis Kenzior
5fc98f5b59 gril: Fix IO reference counting 2016-10-14 16:00:25 +03:00
Denis Kenzior
e7d60078db gril: Remove unused structure members 2016-10-14 16:00:25 +03:00
Denis Kenzior
b6abbc0ece gril: Remove unused header 2016-10-14 16:00:25 +03:00
Denis Kenzior
a7eb318f01 gril: Remove unused function 2016-10-14 16:00:25 +03:00
Denis Kenzior
1674126665 gril: Remove unused function 2016-10-14 16:00:25 +03:00
Alfonso Sanchez-Beato
b1bb48e59f build: Add rilmodem to the build
Build gril, the rilmodem and infineon drivers, and the corresponding
plugins.

Conflicts:
	ofono/Makefile.am
	ofono/configure.ac
2016-10-14 16:00:23 +03:00
Alfonso Sanchez-Beato
abfebddbb9 rildev: plugin that creates ril-type modems
This plugin creates modems that use the rilmodem driver by looking at
environment variables: when OFONO_RIL_DEVICE exists it creates a ril
modem of the sub-type specified by the variable. OFONO_RIL_NUM_SIM_SLOTS
specifies the number of SIM slots for multi-SIM modems.
2016-10-14 15:57:52 +03:00
Alfonso Sanchez-Beato
5fb4a13562 infineon: Definitions for infineon modem 2016-10-14 15:57:52 +03:00
Alfonso Sanchez-Beato
4ff1488b2e infineon: Plugin for infineon modems
Plugin for infineon modems, which is a variant of the ril modem.
2016-10-14 15:57:52 +03:00
Tony Espy
2b4db9a52b ril: Plugin for Android modems
Plugin for Android modem, which uses the rilmodem driver.

Co-authored-by: Tony Espy <espy@canonical.com>
Co-authored-by: Ricardo Salveti de Araujo <ricardo.salveti@canonical.com>
Co-authored-by: Alfonso Sanchez-Beato <alfonso.sanchez-beato@canonical.com>
Co-authored-by: Islam Amer <islam.amer@jollamobile.com>
Co-authored-by: Jussi Kangas <jussi.kangas@tieto.com>
Co-authored-by: Juho Hämäläinen <juho.hamalainen@tieto.com>
Co-authored-by: Martti Piirainen <martti.piirainen@canonical.com>
Co-authored-by: Jarko Poutiainen <Jarko.Poutiainen@oss.tieto.com>
Co-authored-by: Tommi Kenakkala <tommi.kenakkala@oss.tieto.com>
Co-authored-by: Petri Takalokastari <petri.takalokastari@oss.tieto.com>
Co-authored-by: Miia Leinonen <miia.leinonen@oss.tieto.com>
Co-authored-by: Mikko Hurskainen <mikko.hurskainen@nomovok.com>
Co-authored-by: You-Sheng Yang <vicamo.yang@canonical.com>
2016-10-14 15:57:51 +03:00
Tony Espy
05ca5c155b rilmodem: driver for Android modems
Driver for modems that are accessed through the Android Radio Interface
Layer (RIL) for telephony, using the gril library. The driver is almost
feature complete with some exceptions, being CBS and SAT the most
prominent.

Co-authored-by: Tony Espy <espy@canonical.com>
Co-authored-by: Ricardo Salveti de Araujo <ricardo.salveti@canonical.com>
Co-authored-by: Alfonso Sanchez-Beato <alfonso.sanchez-beato@canonical.com>
Co-authored-by: Islam Amer <islam.amer@jollamobile.com>
Co-authored-by: Jussi Kangas <jussi.kangas@tieto.com>
Co-authored-by: Juho Hämäläinen <juho.hamalainen@tieto.com>
Co-authored-by: Petri Takalokastari <petri.takalokastari@oss.tieto.com>
Co-authored-by: Jarko Poutiainen <Jarko.Poutiainen@oss.tieto.com>
Co-authored-by: Tommi Kenakkala <tommi.kenakkala@oss.tieto.com>
Co-authored-by: Miia Leinonen <miia.leinonen@oss.tieto.com>
Co-authored-by: Martti Piirainen <martti.piirainen@canonical.com>
Co-authored-by: You-Sheng Yang <vicamo.yang@canonical.com>
2016-10-14 15:57:51 +03:00
Tony Espy
c55ac50f4c gril: Library to communicate with rild
gril is a library used to communicate with rild, the Android telephony
daemon. Communication happens using a named socket over which binder
parcels are transmitted.

Co-authored-by: Tony Espy <espy@canonical.com>
Co-authored-by: Ricardo Salveti de Araujo <ricardo.salveti@canonical.com>
Co-authored-by: Alfonso Sanchez-Beato <alfonso.sanchez-beato@canonical.com>
Co-authored-by: Mikko Hurskainen <mikko.hurskainen@nomovok.com>
Co-authored-by: You-Sheng Yang <vicamo.yang@canonical.com>
Co-authored-by: Ratchanan Srirattanamet <peathot@hotmail.com>
2016-10-14 15:57:30 +03:00
Simon Fels
aa32435945 hfp_ag_bluez5: register audio card
To let others (PulseAudio) be notified when a handsfree device is
connected with us and can be used for audio routing we need to
expose this by registering a audio card with the correct type.
2016-10-14 15:57:07 +03:00
Denis Kenzior
e940b97389 emulator: Add ofono_emulator_set_handsfree_card 2016-10-14 15:57:07 +03:00
Denis Kenzior
24ba9a3cf7 include: Add ofono_emulator_set_handsfree_card 2016-10-14 15:57:07 +03:00
Denis Kenzior
f7b8c07a3b AUTHORS: Mention Simon's contributions 2016-10-14 15:57:07 +03:00
Simon Fels
159083d9c3 handsfree-audio: add type for our audio cards
When registering audio cards for the handsfree and gateway roles we
need a way for our users to differentiate between both to decide which
of them they start using for their purpose.
2016-10-14 15:57:07 +03:00
Slava Monich
37d7bc057c [ofono] Remove merge artifact 2016-10-14 15:55:57 +03:00
Slava Monich
6d1521313f [ofono] Remove the old rilemodem
It's going to be overwritten by the one coming from upstream.
2016-10-14 15:55:21 +03:00
Slava Monich
1d926b9415 Merge branch 'housekeeping' into 'master'
See merge request !86
2016-10-14 08:52:55 +00:00
Slava Monich
f665278df3 Merge branch 'max_calls' into 'master'
Make sure that maximum number of simultaneous calls is not zero

Some RILs provide NULL string instead of this parameter.
Reported by the community.

See merge request !85
2016-10-14 08:52:07 +00:00
Slava Monich
0bd5130e02 [ofono] Housekeeping
Removed some unnecessary and suplicate code from ril_gprs_context.

Moved ril_address_family to ril_gprs_context.c because it's not used
anywhere else.
2016-10-13 13:10:31 +03:00
Slava Monich
af2c27ea0f [ril] Make sure that maximum number of simultaneous calls is not zero. Fixes MER#1672
Some RILs provide NULL string instead of this parameter.
2016-10-13 12:15:09 +03:00
Slava Monich
3370c09c89 main: Make -d option repeatable
Concatenating the patterns makes more sense than using the last
supplied value and leaking the previous allocated patterns.
2016-10-07 10:48:39 +03:00
Slava Monich
cd23203094 Merge branch 'libmce' into 'master'
Use libmce-glib to track the display state

See merge request !84
2016-10-07 07:48:05 +00:00
Slava Monich
64fcdddaac [ofono] Use libmce-glib to track the display state. JB#36523 2016-10-06 17:36:17 +03:00
Slava Monich
2039b1bd09 Merge branch 'empty' into 'master'
Add EmptyConfig option

See merge request !83
2016-10-03 12:42:56 +00:00
Slava Monich
a52666dc20 [ril] Added EmptyConfig configuration option. Fixes MER#1660
If it's enabled, then all [ril_x] sections are ignored even
if they are present, and no default configuration is created.
2016-10-01 16:43:50 +03:00
Slava Monich
3b4ce1f47b Merge branch 'cached_spn' into 'master'
Don't update SPN while slot is being enabled or disabled

To avoid bothering clients with inconsistent states that make
little sense.

See merge request !82
2016-09-29 10:42:46 +00:00
Slava Monich
d8aefd40c4 [ril] Don't update SPN while slot is being enabled or disabled. Fixes JB#36420
It's better to hold it off until we arrive at a consistent state.
2016-09-28 00:18:15 +03:00
Slava Monich
e79055354c Merge branch 'master' into 'master'
Remove bluez build requirement

There doesn't seem to be any reason for requiring bluez at build time.
Besides since bluez (5) is renamed as bluez5 this won't be compatible
with it.

See merge request !81
2016-09-21 21:45:12 +00:00
Slava Monich
5e75f650c3 Merge branch 'ussd' into 'master'
Don't fail USSD cancel requests

See merge request !80
2016-09-21 21:44:25 +00:00
Jarko Poutiainen
ae782ca6f2 [packaging] remove bluez build requirement.Contributes to JB#36046 2016-09-21 16:10:59 +03:00
Slava Monich
b929a8e8c8 [ril] Don't fail USSD cancel requests from the core. Contributest to JB#36348
If we pass RIL_REQUEST_CANCEL_USSD error to the core, ofono will stay in
its current state and reject the subsequent USSD requests.
2016-09-21 13:41:47 +03:00
Slava Monich
530c3bc812 [ril] Improved parsing of RIL_UNSOL_ON_USSD packets
Particularly, prevent the crash if the USSD type string is missing.
2016-09-21 13:34:15 +03:00
martinjones
0e1a58781f Merge branch 'conf_proto' into 'master'
[ril] Fix creating multiparty and splitting multiparty. Contributes to JB#4743



See merge request !79
2016-08-11 09:41:40 +00:00
Martin Jones
77a26177e5 [ril] Fix creating multiparty and splitting multiparty. Contributes to JB#4743 2016-08-11 09:39:40 +00:00
Slava Monich
f6ea7e4c36 Merge branch 'cf_get_prop' into 'master'
Allow multiple pending org.ofono.CallForwarding.GetProperties

See merge request !77
2016-08-11 08:13:22 +00:00
Slava Monich
babea14604 Merge branch 'jb35840' into 'master'
See merge request !78
2016-07-27 13:24:16 +00:00
Slava Monich
e13ae6d5b3 [ril] Fixed default single-SIM config. Fixes JB#35840
It has to be Jolla1 compatible.
2016-07-27 16:00:54 +03:00
Slava Monich
40ce8f7185 Merge branch 'sim_write' into 'master'
SIM write support

If it's done right, quite a few things (those that have to do with
writing stuff to SIM card) should start working.

See merge request !76
2016-07-25 09:19:54 +00:00
Slava Monich
f68585a784 [ril] Implemented SIM write I/O support. Fixes MER#1199 2016-07-25 12:15:06 +03:00
Slava Monich
16105b8ace [ril] Cleaned up call forwarding code. JB#20921 2016-07-25 12:13:22 +03:00
Slava Monich
91245de799 [ofono] call-forwarding: allow multiple pending GetProperties
The very first call that that every org.ofono.CallForwarding
client makes is GetProperties. With multiple clients, only the
first one was waiting for the completion of the initial query,
all other calls were rejected with org.ofono.Error.InProgress.
In theory, the clients could retry the call later, but in
reality very few clients actually do that.
2016-07-20 22:57:49 +03:00
Slava Monich
c52471132a Merge branch 'pin_retries' into 'master'
Query number of retries left with empty pin

This works with some Qualcomm RILs. Those RILs that don't support
it will fail this request with no harm done. In case if it turns
out to be harmful with some RILs, it can be turned off with
emptyPinQuery=false in ril_subscription.conf

See merge request !75
2016-07-15 14:07:17 +00:00
Slava Monich
a8e7b86733 Merge branch 'band-mode' into 'master'
Query available band modes at startup

With some RIL implementations, RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE
causes some magic Android properties to appear. Otherwise it's
harmless and fairly useless.

See merge request !72
2016-07-15 14:07:00 +00:00
Slava Monich
8829682fad [ril] Query number of retries left with empty pin. MER#1089
This works with some Qualcomm RILs. Those RILs that don't support it
will fail this request with no harm done.

In case if turns out to be harmful with some RILs, it can be turned off
with emptyPinQuery=false in ril_subscription.conf
2016-07-07 11:37:54 +03:00
Slava Monich
246e30d1a5 Merge branch 'locked_pins' into 'master'
Implement SC facility lock query

Otherwise `org.ofono.SimManager` `LockedPins` state gets lost after
ofono is restarted. A few cherry-picks from upstream were required.

See merge request !73
2016-07-07 08:34:25 +00:00
Slava Monich
83267e1fa5 Merge branch 'ril_phonebook' into 'master'
Free phonebook state if export hasn't finished

Fixes memory leaks like these:

==21616== 56 (8 direct, 48 indirect) bytes in 1 blocks are definitely lost in loss record 437 of 520
==21616==    at 0x483F380: malloc (vg_replace_malloc.c:296)
==21616==    by 0x4AEB26F: g_malloc (gmem.c:94)
==21616==    by 0x4B010D9: g_slice_alloc (gslice.c:1025)
==21616==    by 0x4B01FC7: g_slist_append (gslist.c:213)
==21616==    by 0x32553: start_sim_app_read (ril_phonebook.c:860)
==21616==    by 0x3276B: pb_reference_data_cb (ril_phonebook.c:903)
==21616==    by 0x153EB3: sim_fs_op_error (simfs.c:271)
==21616==    by 0x1552BB: sim_fs_op_info_cb (simfs.c:682)
==21616==    by 0x3BBA3: ril_sim_file_info_cb (ril_sim.c:358)
==21616==    by 0x489F679: grilio_channel_handle_packet (grilio_channel.c:711)
==21616==    by 0x489F679: grilio_channel_read (grilio_channel.c:811)
==21616==    by 0x489F679: grilio_channel_read_callback (grilio_channel.c:824)
==21616==    by 0x4AE621B: g_main_dispatch (gmain.c:3154)
==21616==    by 0x4AE621B: g_main_context_dispatch (gmain.c:3769)
==21616==    by 0x4AE64C9: g_main_context_iterate.isra.4 (gmain.c:3840)
==21616== 
==21616== 366 (28 direct, 338 indirect) bytes in 1 blocks are definitely lost in loss record 503 of 520
==21616==    at 0x483F380: malloc (vg_replace_malloc.c:296)
==21616==    by 0x4AEB26F: g_malloc (gmem.c:94)
==21616==    by 0x4B010D9: g_slice_alloc (gslice.c:1025)
==21616==    by 0x4B1076B: g_tree_new_full (gtree.c:217)
==21616==    by 0x324CF: start_sim_app_read (ril_phonebook.c:846)
==21616==    by 0x3276B: pb_reference_data_cb (ril_phonebook.c:903)
==21616==    by 0x153EB3: sim_fs_op_error (simfs.c:271)
==21616==    by 0x1552BB: sim_fs_op_info_cb (simfs.c:682)
==21616==    by 0x3BBA3: ril_sim_file_info_cb (ril_sim.c:358)
==21616==    by 0x489F679: grilio_channel_handle_packet (grilio_channel.c:711)
==21616==    by 0x489F679: grilio_channel_read (grilio_channel.c:811)
==21616==    by 0x489F679: grilio_channel_read_callback (grilio_channel.c:824)
==21616==    by 0x4AE621B: g_main_dispatch (gmain.c:3154)
==21616==    by 0x4AE621B: g_main_context_dispatch (gmain.c:3769)
==21616==    by 0x4AE64C9: g_main_context_iterate.isra.4 (gmain.c:3840)

Those occur if SIM card is removed before phonebook export is finished

See merge request !74
2016-07-07 08:33:47 +00:00
Slava Monich
e1ab11ad25 Merge branch 'configs-mer' into 'master'
configs-mer doesn't need to require ofono

The dependency goes the other way around.

See merge request !71
2016-07-07 08:32:36 +00:00
Slava Monich
a9193282d5 [ril] Fixed another memory leak in RIL phonebook. Fixes to MER#1615 2016-07-07 00:11:27 +03:00
Slava Monich
f80bb5c5bb [ril] Implement facility lock query. Fixes MER#1614 2016-07-06 19:27:34 +03:00
Slava Monich
66eb87777f sim: Query the status of SC facility lock 2016-07-06 19:27:00 +03:00
Denis Kenzior
e5291006fd include: Remove unused query_locked method 2016-07-06 19:27:00 +03:00
Denis Kenzior
c609d7cc07 isi: Change query_locked to query_facility_lock 2016-07-06 19:27:00 +03:00
Denis Kenzior
0de562b019 isimodem: Remove unimplemented query_locked method 2016-07-06 19:27:00 +03:00
Denis Kenzior
60b11f712c atmodem: Change query_locked to query_facility_lock 2016-07-06 19:27:00 +03:00
Samrat Guha Niyogi
80d347b964 sim: Query the status of PS and PN facility locks 2016-07-06 19:27:00 +03:00
Samrat Guha Niyogi
97abd10984 include: Add query_facility_lock method 2016-07-06 19:27:00 +03:00
Slava Monich
5201fc0183 [ril] Free phonebook state if export hasn't finished. Contributes to MER#1615 2016-07-06 12:37:21 +03:00
Slava Monich
14e4ef8e07 [ril] Query available band modes at startup. Contributes to JB#35461 2016-07-04 23:21:23 +03:00
Slava Monich
22bc6d526e [rpm] configs-mer doesn't need to require ofono
The dependency goes the other way around.
2016-07-04 21:20:28 +03:00
Slava Monich
baa4fe30e5 Merge branch 'master' into 'master'
Ensure /var/lib/ofono exists on package.

Directory wasn't being created with new automake.

Makefile.am includes:

statedir = $(localstatedir)/lib/ofono
state_DATA =

Suspect newer just skips it as empty. mkdir should be a safe workaround.

See merge request !69
2016-07-04 16:58:03 +00:00
Slava Monich
d0d0793ccb Merge branch 'allow-data' into 'master'
Add allowDataReq ril_subscription.conf option

That fixes Nexus 5 port. Tested by community.

See merge request !70
2016-07-04 16:56:21 +00:00
Slava Monich
55dd461ce7 [ril] Allow to specify default values in Settings section of ril_subscription.conf
Those will become default for all modems but still can be overwritten in
per-modem config sections.
2016-07-03 16:18:48 +03:00
Slava Monich
4da1a30290 [ril] Added allowDataReq ril_subscription.conf option. Fixes MER#1613
Set to true if your RIL doesn't support RIL_REQUEST_ALLOW_DATA
2016-07-02 14:17:06 +03:00
Slava Monich
303f527d79 [ofono] Deleted obsolete debuglog-api.txt 2016-06-28 14:13:05 +03:00
Pekka Vuorela
27e8621c0b [ofono] Ensure /var/lib/ofono exists on package. Contributes to JB#35132 2016-06-16 15:47:44 +03:00
Slava Monich
200237372a Merge branch 'jb35406' into 'master'
Retry data call on PDP_FAIL_ERROR_UNSPECIFIED

According to comment in android's ril.h, if data call setup fails
with status PDP_FAIL_ERROR_UNSPECIFIED, then we need to silently
retry the call. Let's do that.

See merge request !68
2016-06-07 11:27:31 +00:00
Slava Monich
9cae262c80 [ril] Retry data call on PDP_FAIL_ERROR_UNSPECIFIED. Fixes JB#35406
According to comment in android's ril.h, if data call setup fails
with status PDP_FAIL_ERROR_UNSPECIFIED, then we need to silently
retry the call.
2016-06-07 11:23:49 +03:00
Slava Monich
5e23459b67 Merge branch 'debuglog' into 'master'
Control ofono logging over D-Bus

The previous solution only allowed switching logs on/off, this one
allows to pipe the log to another process.

See merge request !67
2016-05-30 20:29:56 +00:00
Slava Monich
a88d7af6c8 Merge branch 'dtmf' into 'master'
Fix memory trashing after sending DTMF tone

After a DTMF tone was sent,tone_queue buffer was becoming just
a few bytes long but the code kept on assuming that it's still
pointing to at least MAX_DTMF_BUFFER bytes of memory. Under
valgrind it looked like this:

==3914== Invalid write of size 1
==3914==    at 0x4B01AEE: g_strlcat (gstrfuncs.c:1488)
==3914==    by 0x33645: ril_voicecall_send_dtmf (ril_voicecall.c:639)
==3914==    by 0x7EE4B: tone_request_run (voicecall.c:4001)
==3914==    by 0x4AE5B57: g_timeout_dispatch (gmain.c:4577)
==3914==    by 0x4AE521B: g_main_dispatch (gmain.c:3154)
==3914==    by 0x4AE521B: g_main_context_dispatch (gmain.c:3769)
==3914==    by 0x4AE54C9: g_main_context_iterate.isra.4 (gmain.c:3840)
==3914==    by 0x4AE573B: g_main_loop_run (gmain.c:4034)
==3914==    by 0x1F0AF: main (main.c:252)
==3914==  Address 0x591c361 is 0 bytes after a block of size 1 alloc'd
==3914==    at 0x483F380: malloc (vg_replace_malloc.c:296)
==3914==    by 0x4AEA26F: g_malloc (gmem.c:94)
==3914==    by 0x4B0130D: g_strdup (gstrfuncs.c:363)
==3914==    by 0x336AB: ril_voicecall_send_dtmf_cb (ril_voicecall.c:600)
==3914==    by 0x489F679: grilio_channel_handle_packet (grilio_channel.c:711)
==3914==    by 0x489F679: grilio_channel_read (grilio_channel.c:811)
==3914==    by 0x489F679: grilio_channel_read_callback (grilio_channel.c:824)
==3914==    by 0x4AE521B: g_main_dispatch (gmain.c:3154)
==3914==    by 0x4AE521B: g_main_context_dispatch (gmain.c:3769)
==3914==    by 0x4AE54C9: g_main_context_iterate.isra.4 (gmain.c:3840)
==3914==    by 0x4AE573B: g_main_loop_run (gmain.c:4034)
==3914==    by 0x1F0AF: main (main.c:252)

This patch replaces tone_queue with a FIFO ring buffer.

See merge request !66
2016-05-30 19:56:28 +00:00
Slava Monich
290c3d2388 [ofono] Control ofono logging over D-Bus. Contributes to JB#34874
The previous solution only allowed switching logs on/off, this one
allows to pipe the log to another process.
2016-05-30 19:00:42 +03:00
Slava Monich
ee880398ad [ril] Fix memory trashing after sending DTMF tone. Fixes JB#35384 2016-05-30 16:18:23 +03:00
Slava Monich
d65bbc3236 Merge branch 'jb35249' into 'master'
Fix crash on exit if data call setup is pending

See merge request !65
2016-05-17 13:57:18 +00:00
Slava Monich
655544be45 [ril] Fix crash on exit if data call setup is pending. Fixes JB#35249
When context is being removed, the core has already completed its
pending D-Bus request, invoking the completion callback causes
libdbus to panic.
2016-05-16 18:04:34 +03:00
Slava Monich
50a544a191 Merge branch 'default-proto' into 'master'
Use the right data protocol for default context settings

Follow-up to mer-core/ofono!60

See merge request !64
2016-05-14 08:42:27 +00:00
Slava Monich
9e7a4a4d72 [ofono] Use the right data protocol for default context settings. Contributes to JB#32750 2016-05-14 11:40:38 +03:00
Slava Monich
c5b5e3109d Merge branch 'ackretry' into 'master'
Retry RIL_REQUEST_SMS_ACKNOWLEDGE

People report seeing `SMS acknowledgement failed: Further SMS
reception is not guaranteed` message in the log, when they have
some sort of trouble with SMS. Let's see if retry helps.

See merge request !63
2016-04-23 15:48:20 +00:00
Slava Monich
deb106343a [ril] Retry RIL_REQUEST_SMS_ACKNOWLEDGE. Contributes to JB#34851
People report seeing "SMS acknowledgement failed: Further SMS reception
is not guaranteed" message in the log, when they have some sort of trouble
with SMS. Let's see if retry helps.
2016-04-23 12:21:23 +03:00
Slava Monich
771e8becf2 Merge branch 'imei' into 'master'
Fix IMEI query at startup.

See merge request !62
2016-04-22 08:56:45 +00:00
Slava Monich
a0b69f974a [ril] Fixed IMEI query at startup. Fixes JB#34937
IMEI related queries were being completed too early.
2016-04-21 12:25:58 +03:00
Slava Monich
b3a4aaea95 [ofono] Silence "Interface xxx not found on the interface_list" messages
Attempt to remove a modem interface already removed (internally) by ofono
is not an error.
2016-04-20 12:22:33 +03:00
Slava Monich
137e504e10 Merge branch 'jb34928' into 'master'
Prevent crash in ril_delayed_register

See merge request !61
2016-04-19 12:18:32 +00:00
Slava Monich
2de3e445f0 Merge branch 'ipv4v6' into 'master'
Use IPV4V6 for internet contexts by default

Once the packet data protocol is configured, it's saved in the
config file and can be changed via UI. In other words, default
value only affects first-time configuration (i.e. provisioning)
and "Reset to default" function.

See merge request !60
2016-04-19 12:17:57 +00:00
Slava Monich
1cd0d60768 [ril] Prevent crash in ril_delayed_register. Fixes JB#34928
Delayed registration needs to be cancelled by ril_phonebook_remove
if it (registration) hasn't been done yet.
2016-04-19 00:41:33 +03:00
Slava Monich
d1f1f16355 [ofono] Use IPV4V6 (dual) for internet context by default. Fixes JB#32750 2016-04-18 18:59:09 +03:00
Slava Monich
4df72c9376 [ofono] mbpi: Make default packet data protocol configurable. Contributes to JB#32750
Note that according to TS 23.401, UE which is IPv6 and IPv4 capable
should request IPv4v6.
2016-04-18 18:53:50 +03:00
Slava Monich
a35ca2bbd9 [ofono] mbpi: Make MBPI database file configurable at runtime
Useful for provisioning unit tests, if nothing else.
2016-04-18 18:53:28 +03:00
Slava Monich
8376174c76 Merge branch 'oemraw' into 'master'
See merge request !59
2016-04-15 16:12:38 +00:00
Slava Monich
b6f5befcac [ril] Simplify OemRaw D-Bus interface implementation
Since support for this interface has never been merged upstream (and
most likely never will) there is no need to touch ofono core at all.
Moving everything into RIL plugin simplifies the implementation and
allows to delete a few hundred lines of unnecessary code.
2016-04-14 19:03:57 +03:00
Slava Monich
403f29320c [mbpi] Housekeeping 2016-04-13 17:51:32 +03:00
Slava Monich
54209b39bd Merge branch 'jb34842' into 'master'
See merge request !58
2016-04-12 06:48:00 +00:00
Slava Monich
3ca442ad15 [ril] Avoid double completion of data call deactivation requests. Fixes JB#34842
The core expects no more than one completion of each request.
2016-04-11 16:48:40 +03:00
Slava Monich
3a579dd7be [ril] CellInfo D-Bus API optimization. Contributes to JB#34561
As an optimization, CellAdded and CellRemoved signals are replaced with
CellsAdded and CellsRemoved which bring array of paths as a parameter.
Cells typically appear/disappear in bunches.
2016-04-06 11:20:32 +03:00
Slava Monich
a7266fc9c8 [ril] Reset the list of known cells when modem is powered off. Fixes JB#34745 2016-04-05 17:05:31 +03:00
Slava Monich
04dbd344b3 [ril] Unregister cells when removing CellInfo interface 2016-04-05 16:14:39 +03:00
Slava Monich
296534c2a8 Merge branch 'voicecall' into 'master'
Make sure that we don't complete dial request more than once

See merge request !55
2016-03-29 10:26:20 +00:00
Slava Monich
6114482e2a Merge branch 'wait' into 'master'
Startup issues

On some devices, it takes rild some time to become functional.
During that time, it fails many requests, including some critical
ones. For example, RIL_REQUEST_GET_IMSI failure results in
"Unable to read IMSI, emergency calls only" error.

RIL plugin has to retry critical requests to stop ofono from
getting into a non-functional state.

See merge request !54
2016-03-29 10:25:14 +00:00
Slava Monich
8281885ba5 Merge branch 'spn' into 'master'
See merge request !53
2016-03-29 10:22:50 +00:00
Slava Monich
9cd3b84421 [ril] Make sure that we don't complete dial request more than once. Fixes JB#34670 2016-03-27 17:50:57 +03:00
Slava Monich
8d65aaefed [ril] Cache SPN when registered with the home network. Contributes to JB#34131
Some SIM cards don't have EFspn record, i.e. we have no way of knowing the
service provider name. In that happens to be the case, then let's cache
the operator name when we are connected to the home network and use that
as the service provider name. That's a pretty accurate guess.
2016-03-25 18:55:24 +02:00
Slava Monich
ce15cfe48d [ril] Don't register modem until RIL_REQUEST_GET_IMEI completes. MER#1549
Waiting until rild responds to RIL_REQUEST_GET_IMEI (and retrying
the request on failure) gives rild time to finish whatever it's doing
during initialization.
2016-03-25 12:52:14 +02:00
Slava Monich
3a1e37b498 [ril] Retry RIL_REQUEST_GET_IMSI. MER#1549
If we fail the .read_imsi call, ofono gets into "Unable to read IMSI,
emergency calls only" state.
2016-03-25 12:49:35 +02:00
Slava Monich
ecef97dd83 [ril] Retry RIL_REQUEST_SIGNAL_STRENGTH 2016-03-25 12:17:54 +02:00
Slava Monich
a68f1e9c4d [ril] Retry RIL_REQUEST_GET_CURRENT_CALLS 2016-03-25 12:12:30 +02:00
Slava Monich
42808ed0f7 Merge branch 'cellinfo' into 'master'
Add cell info interfaces

See merge request !52
2016-03-24 11:48:37 +00:00
Slava Monich
d896ebcb37 [ril] Added cell info interfaces. Contributes to JB#34561
org.nemomobile.ofono.CellInfo is the modem interface:

    <interface name="org.nemomobile.ofono.CellInfo">
        <method name="GetCells">
            <arg name="paths" type="ao" direction="out"/>
        </method>
        <signal name="CellAdded">
            <arg name="path" type="o"/>
        </signal>
        <signal name="CellRemoved">
            <arg name="path" type="o"/>
        </signal>
    </interface>

and each cell supports org.nemomobile.ofono.Cell interface:

    <interface name="org.nemomobile.ofono.Cell">
        <method name="GetAll">
            <arg name="version" type="i" direction="out"/>
            <arg name="type" type="s" direction="out"/>
            <arg name="registered" type="b" direction="out"/>
            <arg name="properties" type="a{sv}" direction="out"/>
        </method>
        <method name="GetInterfaceVersion">
            <arg name="version" type="i" direction="out"/>
        </method>
        <method name="GetType">
            <arg name="type" type="s" direction="out"/>
        </method>
        <method name="GetRegistered">
            <arg name="registered" type="b" direction="out"/>
        </method>
        <method name="GetProperties">
            <arg name="properties" type="a{sv}" direction="out"/>
        </method>
        <signal name="RegisteredChanged">
            <arg name="registered" type="b"/>
        </signal>
        <signal name="PropertyChanged">
            <arg name="name" type="s"/>
            <arg name="value" type="v"/>
        </signal>
        <signal name="Removed"/>
    </interface>

Supported cell types are "gsm", "wcdma" and "lte", the set of properties
depends on the cell type:

gsm:   mcc,mnc,lac,cid,signalStrength,bitErrorRate
wcdma: mcc,mnc,lac,cid,psc,signalStrength,bitErrorRate
lte:   mcc,mnc,ci,pci,tac,signalStrength,rsrp,rsrq,rssnr,cqi,timingAdvance
2016-03-23 12:49:07 +02:00
Slava Monich
93c57284bd Merge branch 'phonebook' into 'master'
Remove unnecessary SIM I/O, pull in Canonical's RIL phonebook

SIM I/O has to go through ofono core to insure proper sequence of
SIM I/O requests.

Pulled in Canonical's RIL phonebook and ofono core patches required
by it, removed unnecessary code.

See merge request !50
2016-03-21 10:37:30 +00:00
Slava Monich
91436f9643 Merge branch 'import' into 'master'
phonebook: Block all Import requests while import is pending

Only the first one was blocked, other requests were rejected until
import is finished.

See merge request !51
2016-03-21 10:35:29 +00:00
Slava Monich
d0d2587b2a [ofono] phonebook: Block all Import requests while import is pending
Only the first one was blocked, other requests were rejected until
import is finished.
2016-03-21 12:34:30 +02:00
Slava Monich
3e10878348 [ril] Removed unnecessary direct SIM I/O 2016-03-10 18:49:46 +02:00
Slava Monich
6de8c4aa85 [ril] Canonical's RIL phonebook
More or less untouched
2016-03-10 18:36:25 +02:00
Slava Monich
a9da50f890 [ofono] sim: Pull in Canonical's simfs patches
ofono_sim_read_path, ofono_sim_read_info and ofono_sim_read_record
2016-03-10 17:57:41 +02:00
Slava Monich
3ca5161a78 Merge branch 'mce' into 'master'
Refactored mce support

See merge request !49
2016-03-10 07:54:29 +00:00
Slava Monich
03b3ca7776 [ril] Refactored mce support
Since there's only one mce, there's no need to have more than one mce client.
Implemented the initial display state query.
2016-03-09 15:24:34 +02:00
Slava Monich
6e5316aba9 [ril] Housekeeping 2016-03-09 09:42:41 +02:00
Slava Monich
49b752f0ad Merge branch 'mmsdata' into 'master'
Don't force 3G/LTE for MMS data slot

It wasn't doing any good, it only

* looked confusing and unpleasant (e.g. signal strength indicators)
* could result in a missed phone call
* could still take longer than if we just transmit MMS over 2G,
  because switching the network mode takes so long

See merge request !48
2016-03-08 13:48:39 +00:00
Slava Monich
268684eebf [ril] Don't force 3G/LTE for MMS data slot. Fixes JB#34350 2016-03-08 12:56:46 +02:00
Slava Monich
24db1db2b1 Merge branch 'disconnect' into 'master'
Handle the case of data call list changing before disconnect completes

It actually worked even though it was triggering asserts in ril_gprs_context_deactivate_primary_cb()

See merge request !47
2016-03-08 10:55:35 +00:00
Slava Monich
55977c1dac [ril] Handle the case of data call list changing before disconnect completes 2016-03-08 01:15:07 +02:00
Slava Monich
1025a6c6ed Merge branch 'ecclist' into 'master'
Load ECC list from a file

In addition to loading static ECC list from a file, this functionality
can be used to track Android system property by adding something like
this to /init.rc:

on property:ril.ecclist=*
    write /var/lib/ofono/ril.ecclist ${ril.ecclist}
    chmod 0644 /var/lib/ofono/ril.ecclist

See merge request !46
2016-03-07 12:01:42 +00:00
Slava Monich
98a143233d [ril] Load ecclist from a file. Contributes to JB#34084 2016-03-05 12:42:02 +02:00
Slava Monich
88013ff63e Merge branch 'nomodems' into 'master'
Set ready flag if there are no modems at all

See merge request !45
2016-03-04 14:49:45 +00:00
Slava Monich
efbe8b12c9 [ril] Set ready flag if there are no modems at all. Contributes to JB#34456 2016-03-04 16:01:40 +02:00
Slava Monich
ba9cc0eb4a Merge branch 'rat' into 'master'
Don't set preferred network mode if SIM isn't ready

Otherwise we may end up spamming system log with error messages
every 2 seconds.

See merge request !44
2016-03-03 12:49:34 +00:00
Slava Monich
46b5f22464 [ril] Don't set preferred network mode if SIM isn't ready. Fixes JB#34418
Otherwise we may end up spamming system log with error messages
every 2 seconds.
2016-03-02 17:41:58 +02:00
Slava Monich
a31332ebae [rpm] Bumped libglibutil version requirement 2016-03-02 17:41:18 +02:00
Slava Monich
b30141c3d3 Merge branch 'sim' into 'master'
Don't wait for radio power on before indicating SIM presence

I'm not sure why I waited for it in the first place,
probably "just in case".

See merge request !43
2016-03-02 14:00:46 +00:00
Slava Monich
e8ae8bba1c [ril] Don't wait for radio power on before indicating SIM presence. Fixes JB#34351 2016-03-02 14:55:20 +02:00
Slava Monich
3ea25fb81f [ril] Fixed ril_trace in release build 2016-03-02 14:48:12 +02:00
Slava Monich
197df7141d [ril] Ensure that all debug messages have the same syslog priority
So that don't get reordered by the system logger.
2016-03-01 17:23:28 +02:00
Slava Monich
eef6993391 Merge branch 'call' into 'master'
Clear cached callback pointer prior to invoking it

Otherwise we can bump into assert in ril_voicecall_dial

See merge request !42
2016-03-01 15:11:28 +00:00
Slava Monich
f1a5941b35 Merge branch 'handover' into 'master'
Let current data SIM in any slot use 3G/LTE

If 3G/LTE module is shared by the modems and 3G/LTE mode is enabled
for more than one SIM, we need to limit other SIMs to GSM in order
to ensure that the data SIM can use 3G/LTE.

See merge request !37
2016-03-01 15:06:31 +00:00
Slava Monich
5f6a258d0a [ril] Let current data SIM in any slot use 3G/LTE. Fixes JB#33358
If 3G/LTE hardware is shared by both modems, drop the current one to GSM
before switching the data SIM. That allows the other modem to use 3G/LTE.
The downside is that now switching data modems takes longer. This behavior
is configurable with /etc/ofono/ril_subscription.conf
2016-02-29 17:57:03 +02:00
Slava Monich
9fa18f967b [ofono] radio-settings: Made radio_access_mode_to/from_string public
So that they can be used by plugins.
2016-02-29 17:55:07 +02:00
Slava Monich
4d17a2e3b9 [ril] Moved online flag from slot to ril_radio object
To prevent radio power from being turned on when the modem is supposed
to be offline.
2016-02-29 17:54:54 +02:00
Slava Monich
c34b3c39b2 Merge branch 'ready' into 'master'
Add 'ready' flag to ModemManager interface

See merge request !40
2016-02-29 15:50:29 +00:00
Slava Monich
df1824b2e2 [ril] Clear cached callback pointer prior to invoking it.
Otherwise we can bump into assert in ril_voicecall_dial
2016-02-29 17:19:11 +02:00
Slava Monich
b3a18326e1 Merge branch 'pin' into 'master'
Don't expect that SIM changes state after pin change

See merge request !41
2016-02-29 13:44:38 +00:00
Slava Monich
93e564d5e5 [ril] Don't expect that SIM changes state after pin change. Fixes JB#34393 2016-02-29 15:26:10 +02:00
Slava Monich
42847e03b5 [ril] Fixed a memory leak in ril_sim_change_passwd 2016-02-29 15:08:34 +02:00
Slava Monich
f0d6b69972 [ril] Added 'ready' flag to ModemManager interface. Contributes to JB#34203
It allows the client to determine when ofono is done with startup,
i.e. all rild instances are running and have replied to the initial
GET_IMEI and GET_SIM_STATUS requests. At that point it's guaranteed
that ModemManager's SIM presence flags actually reflect the reality.
2016-02-27 02:47:44 +02:00
Slava Monich
2100a8d975 [ril] Removed incorrect asserts in ril_sim_info_handle_sim_state
It receives OFONO_SIM_STATE_NOT_PRESENT when SIM is removed
and there's nothing wrong with that.
2016-02-27 02:46:56 +02:00
Slava Monich
c393e63e4e [ril] Replaced G_INLINE_FUNC with 'static inline'
According to glib docs the use of this macro is strongly discouraged
2016-02-26 16:38:06 +02:00
Slava Monich
b24bc9761b Merge branch 'defaults' into 'master'
Try harder to pick the first SIM as the default

See merge request !39
2016-02-26 14:32:59 +00:00
Slava Monich
06daa7cf21 [ril] Try harder to pick the first SIM as the default. Contributes to JB#34203 2016-02-26 16:30:08 +02:00
Slava Monich
49215d60b2 Merge branch 'ussd' into 'master'
Complete ussd send requests immediately

Otherwise ofono ussd machinery may still be in the IDLE state when
the response arrives, breaking the workflow that involves user action.

See merge request !38
2016-02-22 14:50:13 +00:00
Slava Monich
f3f3b73d6f [ril] Complete ussd send requests immediately. Fixes JB#33891
Otherwise ofono ussd machinery may still be in the IDLE state
when the response arrives, breaking the workflow that involves
user action.
2016-02-22 15:15:45 +03:00
Slava Monich
113d9424b5 Merge branch 'power' into 'master'
See merge request !36
2016-02-18 12:33:12 +00:00
Slava Monich
2a8489c4d9 [ril] Don't power up the modem at startup. Fixes JB#34230
It's powered up when it goes online.
2016-02-18 13:21:57 +03:00
Slava Monich
c4f968b87a Merge branch 'nosimsettings' into 'master'
Remove org.nemomobile.ofono.SimSettings D-Bus interface

It's no longer being used. SIM name is stored in dconf and is of no use
to ofono, enable4G flag is useless - AvailableTechnologies property of
org.ofono.RadioSettings interface tells which radio technologies are
supported.

See merge request !35
2016-02-17 22:01:00 +00:00
Slava Monich
537c7ae8b4 Merge branch 'scan' into 'master'
Allow multiple Scan and (auto) Register requests.

While one of those requests is pending it makes no sense to block
other such requests.

See merge request !33
2016-02-17 22:00:00 +00:00
Slava Monich
b320fc7f59 [ril] Removed org.nemomobile.ofono.SimSettings D-Bus interface. Contributes to JB#34189
It's no longer being used. SIM name is stored in dconf and is of
no use to ofono, enable4G flag is useless - AvailableTechnologies
property of org.ofono.RadioSettings interface tells which radio
technologies are supported.
2016-02-11 22:00:29 +03:00
Slava Monich
edf49e6e99 [ril] Replaced assert with a comment 2016-02-10 12:24:53 +03:00
Slava Monich
b7985a1d67 Merge branch 'null' into 'master'
Fix crash on unexpected DATA_CALL_LIST payload

Debug trace didn't check pointers for NULL

See merge request !32
2016-02-08 11:35:24 +00:00
Slava Monich
bbb2c68a72 [ofono] network: Allow multiple Scan and (auto) Register requests.
While one of those requests is pending it makes no sense to
block other such requests.
2016-02-07 13:46:27 +03:00
Slava Monich
bd3f7f35eb [ril] Fixed crash on unexpected DATA_CALL_LIST payload
Debug trace didn't check pointers for NULL
2016-02-06 17:36:24 +03:00
Slava Monich
65bf1a24fa Merge branch 'sim_info' into 'master'
Slightly more generic handling of ofono watchlists

Without registering the free watch callback we can't be sure
whether the watchlist is still alive and that it's safe to call
the watch remove function (if the corresponding watchlist is
already deallocated, the ofono core may choose to crash). This
patch adds generic remove callback ril_sim_info_watch_done() for
all watches and fixes a few minor unrelated issues.

See merge request !31
2016-02-05 09:40:35 +00:00
Slava Monich
0c37015145 [ril] sim_info: Slightly more generic handling of ofono watchlists 2016-02-03 19:39:26 +02:00
Slava Monich
a8551cdce7 [ril] Housekeeping 2016-02-03 17:26:24 +02:00
Slava Monich
5bd2b96240 Merge branch 'mtu' into 'master'
MTU watcher

rild, modem driver or whatever is changing MTU of the mobile
data network interface without informing us. Since we don't
get any notifications from rild when that happens, the solution
that I came up with turned out to be slightly more complicated
than I hoped. But it works.

See merge request !30
2016-02-02 16:22:46 +00:00
Slava Monich
3bf309b887 [ofono] gprs: Took MTU management out of the ofono core
These changes have never been merged upstream and partially
duplicate MTU watcher (part of the RIL plugin).
2016-02-02 18:19:07 +02:00
Slava Monich
c14b9bbf93 [ril] MTU watcher. Fixes JB#33639
rild, modem driver or whatever is changing MTU of the mobile data
network interface without informing us. We don't want MTU to be
greater than 1280.
2016-02-02 18:19:07 +02:00
Slava Monich
568bd615cd Merge branch 'siminfo' into 'master'
org.nemomobile.ofono.SimInfo interface

Allows the client to fetch cached SubscriberIdentity and ServiceProviderName before the pin code is entered. ICCID
to IMSI map is stored in /var/lib/ofono/iccidmap, cached
SIM properties in /var/lib/ofono/IMSI/cache
2016-02-02 16:17:15 +00:00
Slava Monich
4d55f94015 [ril] Added org.nemomobile.ofono.SimInfo interface. Contributes to JB#34053
Allows the client to fetch cached SubscriberIdentity and
ServiceProviderName before the pin code is entered.
2016-01-31 17:08:27 +02:00
Slava Monich
95d06963cd [ofono] sim: Add iccid and imsi watches 2016-01-31 17:08:27 +02:00
Slava Monich
479458138a [ofono] watch: Ensure that watch id is non-zero 2016-01-31 17:08:27 +02:00
Slava Monich
c221d677d1 [rilmodem] Fixed compilation of the old rilmodem code 2016-01-31 16:48:06 +02:00
Slava Monich
a32da19192 [ril] Fixed possible crash on exit
==5482== Invalid free() / delete / delete[] / realloc()
==5482==    at 0x4840ABC: free (vg_replace_malloc.c:473)
==5482==    by 0x206E7: ril_data_call_setup_free (ril_data.c:727)
==5482==    by 0x1FE17: ril_data_call_request_free (ril_data.c:490)
==5482==    by 0x1FFC7: ril_data_call_request_cancel (ril_data.c:537)
==5482==    by 0x21707: ril_data_dispose (ril_data.c:1103)
==5482==    by 0x4A1EE57: g_object_unref (gobject.c:3160)
==5482==    by 0x21177: ril_data_unref (ril_data.c:971)
==5482==    by 0x2C32F: ril_plugin_shutdown_slot (ril_plugin.c:223)
==5482==    by 0x2EC2F: ril_plugin_delete_slot (ril_plugin.c:1023)
==5482==    by 0x2F077: ril_plugin_destroy_slot (ril_plugin.c:1127)
==5482==    by 0x4ACE9AF: g_slist_foreach (gslist.c:896)
==5482==    by 0x4ACE9C1: g_slist_free_full (gslist.c:179)
==5482==  Address 0x5bf1c40 is 0 bytes inside a block of size 48 free'd
==5482==    at 0x4840ABC: free (vg_replace_malloc.c:473)
==5482==    by 0x206E7: ril_data_call_setup_free (ril_data.c:727)
==5482==    by 0x1FE17: ril_data_call_request_free (ril_data.c:490)
==5482==    by 0x1FFC7: ril_data_call_request_cancel (ril_data.c:537)
==5482==    by 0x24A2B: ril_gprs_context_remove (ril_gprs_context.c:601)
==5482==    by 0x134803: gprs_context_remove (gprs.c:2841)
==5482==    by 0xDFD73: flush_atoms (modem.c:429)
==5482==    by 0xE002F: modem_change_state (modem.c:507)
==5482==    by 0xE0C7F: set_powered (modem.c:878)
==5482==    by 0xE3E5B: __ofono_modem_shutdown (modem.c:2207)
==5482==    by 0xDDDE7: signal_handler (main.c:77)
==5482==    by 0x4AB1B85: g_main_dispatch (gmain.c:3066)
==5482==    by 0x4AB1B85: g_main_context_dispatch (gmain.c:3642)
2016-01-31 03:24:25 +02:00
Slava Monich
a20da10621 [ril] Fixed assert in dbus library. Contributes to JB#28417
It doesn't like NULL strings so much that it terminates the app.
2016-01-30 00:37:50 +02:00
Slava Monich
64c754c3b9 [ril] Housekeeping
Use G_SOURCE_REMOVE instead of FALSE where appropriate
2016-01-29 17:48:13 +02:00
Slava Monich
d64fd7dca7 Merge branch 'enable4G' into 'master'
Remove Enable4GChanged signal from the introspection data

Enable4G flag never changes, therefore this signal is never sent.
    
Even though this flag it not being used by the UI anymore,
it still has to be kept it around to avoid breaking D-Bus API.

See merge request !28
2016-01-29 15:16:12 +00:00
Slava Monich
f608c0821a [ril] Remove Enable4GChanged signal from the introspection data
Enable4G flag never changes, therefore this signal is never sent.

Even though this flag it not being used by the UI anymore, it still
has to be kept it around to avoid breaking D-Bus API.
2016-01-29 12:43:01 +02:00
Slava Monich
7d29ef130a Housekeeping 2016-01-26 15:37:10 +02:00
Slava Monich
141eadee1d Merge branch 'mmssim' into 'master'
Add Get/SetMmsSim functionality

If MMS data SIM is different from the default data SIM, then MMS SIM
is selected for data and defaultDataModem is emptied, which tells
connman not to mess with mobile data while MMS is being transmitted.

SetMmsSim returns the path of the modem where the requested SIM is
or an empty string if there's no such SIM (or it's locked). This
information may or may not be useful to the client.
    
The behaviour gets reset back to default when IMSI of the MMS SIM is
set to empty string or the client which set it, exits. The client is
going to be mms-engine.

See merge request !26
2016-01-26 13:29:39 +00:00
Slava Monich
e84602d79c [ril] Add Get/SetMmsSim functionality. Contributes to #28417
If MMS data SIM is different from the default data SIM, then MMS SIM
is selected for data and defaultDataModem is emptied, which tells connman
not to mess with mobile data while MMS is being transmitted.

SetMmsSim returns the path of the modem where the requested SIM is
or an empty string if there's no such SIM (or it's locked).

The behaviour gets reset back to default when IMSI of the MMS SIM
is set to empty string or the client which set it, exits.
2016-01-26 02:10:07 +02:00
Slava Monich
b63b6355d5 [ril] Moved context setup and deactivation to ril_data. Contributes to JB#33358
This will allow to properly serialize the actions when switching
the data SIMs.
2016-01-26 02:10:07 +02:00
Slava Monich
f7f007a122 Merge branch 'EFspn' into 'master'
Add ServiceProviderName property to SimManager

Contains the service provider name fetched from the SIM card, if available.

See merge request !27
2016-01-25 23:57:21 +00:00
Slava Monich
5769656848 [ofono] sim: Add ServiceProviderName property to SimManager
Contains the service provider name fetched from the SIM card, if available.
2016-01-26 00:21:23 +02:00
Slava Monich
bbc276b4c7 [ril] Reduced the amount of debug trace produced by ril_radio.c 2016-01-23 18:53:05 +02:00
Slava Monich
4b79de53fe [gprs] Removed unnecessary debug trace 2016-01-21 14:05:11 +02:00
Slava Monich
12ffd8acf9 Merge branch 'post-1.17-picks' into 'master'
Cherry-picked useful post-1.17 commits + a simple bug fix on top of it.

See merge request !25
2016-01-20 13:47:17 +00:00
Slava Monich
df9b35b440 [ril] Set correct status for the current operator. Fixes JB#33922 2016-01-20 11:33:27 +02:00
John Ernberg
76e991d3da network: Fix crash caused by empty Scan() results
When issuing a Scan() in poor reception while attached to an operator it's
fully possible to get no results, which causes the attached operator to be
cleaned up. In certain scenarios this would cause a use-after-free as there
are still references to this operator.
Transfer the attached operator to the new list regardless of removal caused
by the Scan() results.
2016-01-20 11:33:27 +02:00
John Ernberg
90803904be gprs: Fix the ContextAdded() signal Introspection
This matches the behavior described by the documentation the signal
value returned by the code. This was causing a headache when using
stricter D-Bus wrappers like dbus-c++.
2016-01-20 11:33:27 +02:00
John Ernberg
84e547c2ed cbs: Resolve a use-after-free
In situations where location changes rapidly, a use-after-free condition
can occur.  What happens is that the timeout leaks and then the cbs
struct with the callback is cleaned up, resulting in a SIGSEGV when the
callback occurs from the glib loop.
2016-01-20 11:33:27 +02:00
Denis Kenzior
652798d592 modem: Don't move to pre-sim state in case of failure
In ofono_modem_reset, if the enable() callback fails, do not
proceed to the pre-sim state
2016-01-20 11:33:27 +02:00
Denis Kenzior
979a3bcef3 gprs: Implement ofono_gprs_context_get_type 2016-01-20 11:33:27 +02:00
Denis Kenzior
69178c8ecb include: Add ofono_gprs_context_get_type 2016-01-20 11:33:27 +02:00
Slava Monich
1ac1c9268d [gprs] Remove redundant ofono_gprs_get_modem declarations
Upstream now has those too.
2016-01-20 11:33:27 +02:00
Denis Kenzior
5483a8ecc0 gprs: Implement ofono_gprs_get_modem 2016-01-20 11:33:27 +02:00
Denis Kenzior
95dacebb0c gprs: Add ofono_gprs_get_modem() 2016-01-20 11:33:27 +02:00
Simon Fels
b92b1ce13f voicecall: don't dereference a supplied null value
When the voicecall atom is unregistered we remove all HFP support as
well but were supplying a zero as value to the emulator status
callbacks which caused the process to crash as we were dereferencing
the supplied value always and not respecting a zero as indicator to
reset.
2016-01-20 11:33:27 +02:00
Denis Kenzior
70ab2175a0 gprs: Allow synchronous callbacks for set_attached 2016-01-20 11:33:27 +02:00
Denis Kenzior
9810a258a1 radio-settings: Implement get_modem() 2016-01-20 11:33:27 +02:00
Denis Kenzior
760c17052f include: Add ofono_radio_settings_get_modem() 2016-01-20 11:33:27 +02:00
Denis Kenzior
e77b62a91e doc: Add Item M17 to coding-style.txt 2016-01-20 11:33:27 +02:00
Alfonso Sanchez-Beato
7103c81a77 include: Add definitions for phone number types 2016-01-20 11:33:27 +02:00
Slava Monich
2bc610353d [ril] Removed redundant declaration of enum operator_status
It has become public
2016-01-20 11:33:27 +02:00
Tony Espy
dd04ac248d src: make bearer/operator enums public
Move enums for operator_status and packet_bearer to common.h to avoid
duplication in drivers.
2016-01-20 11:33:27 +02:00
Slava Monich
c5b3357000 Merge branch 'merge-1.17' into 'master'
Upgrade to ofono 1.17

Some of the commits look quite useful and yet the whole thing doesn't seem to be particularly destructive (unlike what started happening after 1.17).

See merge request !24
2016-01-20 09:19:42 +00:00
Slava Monich
ddbdf9f649 Merge tag '63f6a75a61e7e07cc773929acb4c13acaf8a4b00' into merge-1.17
Release 1.17

Conflicts:
	ofono/src/gprs.c
	ofono/src/log.c
	ofono/src/main.c
	ofono/src/sim.c
2016-01-19 14:30:45 +02:00
Slava Monich
7b5be51527 [ofono] Update to upstream 1.17 2016-01-19 14:26:00 +02:00
Alfonso Sanchez-Beato
5aef6a8356 sms: Add trace when datagram is not delivered 2016-01-19 14:19:33 +02:00
Alfonso Sanchez-Beato
b99cd4f8ca smsutil: Do not check the origin port
Do not check if the origin port is reserved, as some operators use that
range of values.
2016-01-19 14:18:23 +02:00
Alfonso Sanchez-Beato
47ee85e955 push-notification: Accept push from any origin
Accept push notifications regardless of the origin port, as some
operators do not insert there the WAP connectionless session service
port, and use random values instead.
2016-01-19 14:17:39 +02:00
Denis Kenzior
b500f4fa65 voicecall: Don't accept USSD strings in Dial() 2016-01-19 14:16:01 +02:00
Denis Kenzior
c2c048dc05 gprs: Try re-attaching when we switch cells 2016-01-19 14:15:09 +02:00
Alfonso Sanchez-Beato
df923b481f message-waiting: Fix reading EF_MWIS records 2016-01-19 14:14:13 +02:00
Alfonso Sanchez-Beato
ed0c1f94f6 message-waiting: Update properly EF_MWIS SIM file 2016-01-19 14:13:44 +02:00
Marko Sulejic
6d2852cdaf configure.ac: fix typo 2016-01-19 14:13:00 +02:00
Denis Kenzior
72a1ecf5d0 sim: Fix up whitespace issues 2016-01-19 14:12:14 +02:00
Alfonso Sanchez-Beato
2fa10fb265 gprs: Add comment to gprs_reset_contexts 2016-01-19 14:10:53 +02:00
Denis Kenzior
f907c3a85d test: Fix file mode for reset-contexts 2016-01-19 14:10:28 +02:00
Alfonso Sanchez-Beato
4a7b325191 gprs: Refactor to remove forward declaration 2016-01-19 14:09:58 +02:00
Alfonso Sanchez-Beato
a8103a39fa test: Add script for resetting contexts 2016-01-19 14:07:35 +02:00
Alfonso Sanchez-Beato
4076502017 doc: Add description for ResetContexts method 2016-01-19 14:07:28 +02:00
Alfonso Sanchez-Beato
7ed41beadd gprs: Add DBus method to reset contexts
Add DBus method that removes the current contexts and re-provisions
using the APN database.

Conflicts:
	ofono/src/gprs.c
2016-01-19 14:06:26 +02:00
Luiz Augusto von Dentz
e45389cf84 gdbus: Close private connection if setup fails
Private connection should be properly closed with dbus_connection_close
otherwise libdbus exits with the following error:

  'The last reference on a connection was dropped without closing the
   connection. This is a bug in an application. See
   dbus_connection_unref() documentation for details. Most likely, the
   application was supposed to call dbus_connection_close(), since this
   is a private connection.'
2016-01-19 14:01:44 +02:00
Szymon Janc
4bae61c83e gdbus: Fix crash in g_dbus_create_error_valist
Passing NULL format parameter to vsnprintf results in invalid argument
error on glibc. But with some other libc libraries (musl and uClibc)
this results in dereferencing NULL pointer and crash due to
segmentation fault.
2016-01-19 14:01:37 +02:00
Szymon Janc
11d6e76f0a gdbus: Use g_dbus_create_error_valist internally
There is no need to duplicate code in g_dbus_send_error_valist.
2016-01-19 14:01:27 +02:00
Michael Janssen
4cfa5cdf36 gdbus: Add g_dbus_get_flags function
The g_dbus_get_flags function enables detection of when the
G_DBUS_FLAG_ENABLE_EXPERIMENTAL is set.
2016-01-19 14:01:17 +02:00
Luiz Augusto von Dentz
135923532c gdbus: Make GDBusClient work without ObjectManager
This makes GDBusClient work normally without ObjectManager.
2016-01-19 14:01:11 +02:00
Arman Uguray
d112c042e3 gdbus/client: Allow specifying ObjectManager path
GDBusClient currently hard-codes "/" as the remote ObjectManager path.
This is generally incorrect, as an application can choose to expose an
ObjectManager at any well-known path. This patch fixes this by allowing
the user to pass in the ObjectManager path by introducing a new
conctructor "g_dbus_client_new_full".
2016-01-19 14:01:02 +02:00
Arman Uguray
b9407ff65f gdbus/client: Don't GetManagedObjects w/o handlers
The client code currently issues GetManagedObjects if new handlers are
set via g_dbus_client_set_proxy_handlers. An application may set these
to NULL before unref'ing a client or to simply prevent further events.
Hence, there is no need to refresh objects or properties if all handlers
are NULL.
2016-01-19 14:00:55 +02:00
Szymon Janc
5a92625c9f gdbus: Fix not calling disconnect function
If daemon gets disconnected from D-Bus sender is NULL. Watches that
was explicitly added with NULL sender (ie disconnected_signal in
g_dbus_set_disconnect_function) should be called anyway.
2016-01-19 14:00:40 +02:00
Arman Uguray
c684033671 gdbus: Don't refresh objects/props if disconnected
If g_dbus_client_set_proxy_handlers gets called from within a
proxy_removed callback, the code may end up refreshing the proxy's
properties and incorrectly access the client's proxy_list as it gets
freed. This patch fixes this, so that get_managed_objects does nothing
if it gets called during a service disconnect.
2016-01-19 13:53:41 +02:00
Slava Monich
59cb9c39b9 Merge branch 'jb33872' into 'master'
Fix eternal loop loop with roaming SIM

When ofono core is asking gprs driver to detach (because data roaming is disabled), it's expecting data registration status to change. If that doesn't happen, it starts all over again.

See merge request !22
2016-01-18 15:26:47 +00:00
Slava Monich
0831fd803a [ril] Tweaking mobile data management
Mobile data availability for all slots is now managed by the single
component called ril_data_manager.
2016-01-18 12:28:18 +02:00
Slava Monich
1b6c20759c [ril] Fix eternal loop with roaming sim. Fixes JB#33872
When ofono core is asking gprs driver to detach (because data
roaming is disabled), it's expecting data registration status
to change. If that doesn't happen, it starts all over again.
2016-01-18 12:28:18 +02:00
Slava Monich
3681eb63b1 Merge branch 'voicereg' into 'master'
Allow 3 values for registration state response

This was seen by one of the porters:
```
RIL< [0000000a] VOICE_REGISTRATION_STATE
RIL> [0000000a] OK
RIL> 0000: 00 00 00 00 0a 00 00 00  00 00 00 00 03 00 00 00    ........ ........
RIL  0010: 01 00 00 00 30 00 00 00  04 00 00 00 30 00 30 00    ....0... ....0.0.
RIL  0020: 30 00 30 00 00 00 00 00  08 00 00 00 30 00 30 00    0.0..... ....0.0.
RIL  0030: 30 00 30 00 30 00 30 00  30 00 30 00 00 00 00 00    0.0.0.0. 0.0.....
ofonod[953]: drivers/ril/ril_network.c:ril_network_parse_response() broken response
```

See merge request !23
2016-01-18 10:26:50 +00:00
Slava Monich
5303f766a9 [ril] Provide reasonable default for max_calls
Some older RILs don't provide max calls, in that case let's supply
some reasonable default. We don't need more than 2 simultaneous data
calls anyway.
2016-01-18 00:13:41 +02:00
Slava Monich
2f68eeea6c [ril] Allow 3 values for registration state response 2016-01-17 17:08:42 +02:00
Slava Monich
7a7744781a Merge branch 'imei' into 'master'
Return cached IMEI values from query_serial

Those are always queried at startup and they never change. There's no reason to perform RIL query for IMEI more than once.

See merge request !21
2016-01-14 21:15:23 +00:00
Slava Monich
fc1491c634 [ril] Return cached IMEI values from query_serial
Those are always queried at startup and they never change.
There's no reason to perform RIL query for IMEI more than once.
2016-01-14 16:48:38 +02:00
Slava Monich
c631a48c41 [ril] Set gprs cid range when registering gprs driver. Fixes JB#33861
There is no need to wait for the network state status, the network
may already be operational. Without cid range, attempts to activate
connection context will fail with org.ofono.Error.NotImplemented
2016-01-13 18:08:15 +02:00
Slava Monich
21e90e5abd Housekeeping 2016-01-13 16:52:36 +02:00
Slava Monich
bfcf8b726b Merge branch 'reg_state' into 'master'
Fixed a few issues mostly affecting startup and slowing down sim initialization

1. Don't submit the initial network state request if RIL says that radio is off. I have the impression that RIL doesn't like it; besides it won't work anyway. Instead, wait for radio on or for the network state change event, whichever comes first.
2. When the network state or sim status event occurs and the corresponding query is scheduled to be retried after a failure, retry it right away (i.e. don't wait for the retry timeout to expire).

Requires libgrilio 1.0.6 (already merged) which includes the bug fix for retries happening 1000 times too often (which rild might not like too).

See merge request !19
2016-01-13 14:49:20 +00:00
Slava Monich
3b69c9843b Merge branch 'lastcause' into 'master'
Handle more cause values for call control.

Quite many normal disconnect causes defined in 3GPP TS 24.008 Annex H
are not handled and are thus treated as errors. telepathy-ring would
then play "network out of order" tone, when "busy" tone would be more
appropriate. Add all the call control cause values not defined in ril.h
(but defined in Annex H) here and handle them appropriately.

See merge request !20
2016-01-13 13:58:48 +00:00
Juho Hämäläinen
f24252e2c6 Handle more cause values for call control. Fixes MER#1461
Quite many normal disconnect causes defined in 3GPP TS 24.008 Annex H
are not handled and are thus treated as errors. telepathy-ring would
then play "network out of order" tone, when "busy" tone would be more
appropriate. Add all the call control cause values not defined in ril.h
(but defined in Annex H) here and handle them appropriately.
2016-01-13 15:08:44 +02:00
Slava Monich
4be4cb4f57 [ril] Poke enabled modems with RADIO_POWER request after any modem gets powered off. Fixes JB#33830
If we don't do it, bad things may happen (like the enabled and
apparently powered on modem never registering on the network).
This may have something to do with certain pieces of radio
circuitry being shared by all modems.
2016-01-13 14:38:33 +02:00
Slava Monich
9d4f682b14 [ril] Fixed GET_SIM_STATUS retry 2016-01-13 00:01:02 +02:00
Slava Monich
bd736f7aa6 [ril] Only query the initial network state only if radio is on
Otherwise wait for the network state change event
2016-01-13 00:00:39 +02:00
Slava Monich
ff328c2a73 [systemd] Add $OFONO_DEBUG to the service command line
This allows to put a conf file to /var/lib/environment/ofono/ which
defines OFONO_DEBUG and avoid modifying ofono.service after each update.
2016-01-12 16:29:38 +02:00
Slava Monich
10e908fa96 Merge branch 'ril_subscription' into 'master'
Updated sample ril_subscription.conf

The comments in gril/ril_subscription.conf are not relevant to ril plugin in drivers/ril

See merge request !18
2016-01-11 12:45:56 +00:00
Slava Monich
4aa59c7274 Merge branch 'uicc_sub' into 'master'
Use different SET_UICC_SUBSCRIPTION codes for different RIL versions

RIL_REQUEST_SET_UICC_SUBSCRIPTION is 115 in RIL version 9 (or earlier) and 122 in RIL version 10 and later. Since we don't know in advance which RIL version we are dealing with, we need to make the decision at runtime.

See merge request !17
2016-01-11 12:45:29 +00:00
Slava Monich
d61be44bb4 [ril] Updated sample ril_subscription.conf 2016-01-11 13:16:10 +02:00
Slava Monich
0ed1ef1e4c [ril] Use different SET_UICC_SUBSCRIPTION codes for different RIL versions. Fixes MER#1446
RIL_REQUEST_SET_UICC_SUBSCRIPTION is 115 in RIL version 9 (or earlier)
and 122 in RIL version 10 and later. Since we don't know in advance which
RIL version we are dealing with, we need to make the decision at runtime.
2016-01-11 12:59:58 +02:00
Slava Monich
2fa193ad5b Merge branch 'sim_card' into 'master'
Refactoring of SIM card, network and radio power management

Major refactoring aimed at improving predictability, reliability and reducing RIL socket traffic. For instance, SIM card, radio and network states are now represented at the ofono side by dedicated per-socket objects and state changes are indicated to the interested parties using glib signalling mechanism (as opposed to independently listening to RIL events and performing redundant queries).

Requires libgrilio 1.0.4 (already merged)

See merge request !16
2016-01-11 08:46:48 +00:00
Slava Monich
e686240eeb [ril] Allow to control libgrilio logging with ofono -d option
It can be turned on with -d grilio or via D-Bus
2016-01-10 16:05:58 +02:00
Slava Monich
18bc7a3ad8 [ril] Use libgrilio built-in retry mechanism 2016-01-08 23:20:34 +02:00
Slava Monich
6624066917 [ril] Let gprs driver control "allow data" setting
Also added ril_network object that keeps track of the network state and
reduces the number of RIL requests.
2016-01-07 16:56:12 +02:00
Slava Monich
6015490d41 [ril] Indicate SIM card presence in appropriate radio state. Contributes to JB#33805
This also reduces the number of GET_SIM_STATUS requests. Only one object
per RIL instance makes these requests, the results are shared by all
other objects involved.

In addition to that, radio power on request is retried if radio power
unexpectedly switches off which does happen on multi-sim hardware.
2016-01-07 15:54:14 +02:00
Slava Monich
a135d0ea52 [ril] Sync constants with the latest Android ril.h 2016-01-07 15:47:30 +02:00
Slava Monich
f86159c180 [ril] Reset data modem pointer after default data SIM is gone 2015-12-15 12:38:53 +03:00
Slava Monich
de2b622f3b Merge branch 'radio-settings' into 'master'
Radio settings

Fixes `org.ofono.RadioSettings.GetProperties` failures after switching SIM cards and adds support for `"AvailableTechnologies"` property.

See merge request !13
2015-12-15 09:33:36 +00:00
Slava Monich
077f3f2e1e [ril] radio_settings: Implemented query_available_rats, removed obsolete code 2015-12-09 16:49:20 +03:00
Slava Monich
acbd40f9ad [ofono] radio-settings: Queue GetProperties requests
Just after the modem is added and org.ofono.RadioSettings interface
is registered, ofono may receive a number of GetProperties calls for
this interface. The first one would wait for initial queries to
complete while others may fail.

I guess it was expected that clients would retry the call later
but in practice pretty much all clients treat any D-Bus error as
a permanent failure.

This commit introduces the list of pending GetProperties requests
which all get completed after the initial query is done.
2015-12-09 14:03:24 +03:00
Slava Monich
26398c769f Merge branch 'PrefixLength' into 'master'
Provide PrefixLength for IPv6 address

`PrefixLength` property was absent from ConnectionContext IPv6.Settings even if it's provided by RIL.

See merge request !12
2015-12-02 15:33:27 +00:00
Slava Monich
60c53428f0 [ril] Provide PrefixLength for IPv6 address. Contributes to JB#31859 2015-12-02 15:05:21 +02:00
Slava Monich
90824a8906 Merge branch 'jb33531' into 'master'
Queue org.ofono.MessageManager.GetProperties requests while waiting for sca_query

Just after the modem is added and `org.ofono.MessageManager` interface is registered, ofono receives a bunch of `GetProperties` calls for this interface. The first one would wait for `driver->sca_query` completion and all others would fail until `driver->sca_query` completes. I guess it was expected that clients would retry the call later but in practice pretty much all clients treat any D-Bus error as a permanent failure.

This commit introduces the list of pending `GetProperties` requests which all get completed when `driver->sca_query` is done.

See merge request !11
2015-11-30 14:16:47 +00:00
Slava Monich
b85b8f0019 [ofono] sms: Queue GetProperties requests while waiting for sca_query. Fixes JB#33531
Just after the modem is added and org.ofono.MessageManager interface
is registered, ofono receives a bunch of GetProperties calls for this
interface. The first one would wait for driver->sca_query completion
and all others would fail until driver->sca_query completes.

I guess it was expected that clients would retry the call later
but in practice pretty much all clients treat any D-Bus error as
a permanent failure.

This commit introduces the list of pending GetProperties requests
which all get completed when driver->sca_query is done.
2015-11-30 16:11:54 +02:00
Slava Monich
29069fd152 Merge branch 'imei' into 'master'
Add GetIMEI method to ModemManager

This allows to query IMEI of all available modems without having to register them with ofono.

See merge request !10
2015-11-13 16:09:28 +00:00
Slava Monich
8e4e88e4fc [ril] Added GetIMEI method to ModemManager. Contributes to JB#33484
This allows to query IMEI of all available modems without having
to register them with ofono.
2015-11-12 17:59:05 +02:00
Slava Monich
40f148c134 [ril] Fixed memory leak on ofono_modem_register() failure 2015-11-12 17:51:35 +02:00
Slava Monich
730d5ff9b5 [ofono] modem: Destroy modem->properties in ofono_modem_remove()
Since it's created in ofono_modem_create(), it has to be destroyed
in ofono_modem_remove() to avoid memory leaks if ofono_modem_register()
fails.
2015-11-12 17:49:13 +02:00
Slava Monich
c6000fd909 Merge branch 'jb33441' into 'master'
Fix double free on self-deactivation of GPRS context



See merge request !9
2015-11-12 08:12:01 +00:00
Slava Monich
f2edab4ed8 Merge branch 'jb33265' into 'master'
Add GetPresentSims to ModemManager interface

Only a simple boolean (presence/absence) is reported. `PresentSimsChanged` signal is emitted when SIM is inserted or removed (if RIL supports it).

See merge request !8
2015-11-12 08:11:38 +00:00
Slava Monich
9915ccb3ba [ril] Fixed double free on self-deactivation of GPRS context. Fixes JB#33441 2015-11-11 19:20:24 +02:00
Slava Monich
b5be8420ab [ril] Add GetPresentSims to ModemManager interface. Contributes to JB#33265
Only a simple boolean (presence/absence) is reported. PresentSimsChanged
signal is emitted when SIM is inserted or removed (if RIL supports it).
2015-11-11 17:14:32 +02:00
Slava Monich
5498e22839 Merge branch 'jb33299' into 'master'
Fix manual operator selection for L500D

Seems to work on both Jolla1 and L500D

See merge request !7
2015-11-10 09:43:10 +00:00
Slava Monich
802d351ab0 Merge branch 'mer1394' into 'master'
Fix memory leaks

Memory was leaking every time a new SIM is inserted or "Reset to default" is done from AP settings page. Also refactored `provision_normalize_apn_list()` to eliminate duplicate code and clearly separate AP selection criteria into the sorting callback function.

See merge request !6
2015-11-10 09:42:52 +00:00
Slava Monich
3d62d57d20 [ril] Append +0 to MCCMNC in network selection request. Fixes JB#33299
Some RILs report MCCMNC in MCCMNC+TECH format and seem to expect it
in a similar way in SET_NETWORK_SELECTION_MANUAL request. Older RILs
don't require it but don't have a problem with that sort of syntax
either, at least one particular QCRIL vesion 6 that I tried. So the
solution seems to be quite portable.
2015-11-09 16:29:12 +02:00
Slava Monich
3b1b272967 [ril] Eliminated unnecessary debug print 2015-11-09 16:28:44 +02:00
Slava Monich
5e2a7afabd [ril] Fixed conversion of RIL to ofono registration status 2015-11-09 16:25:14 +02:00
Slava Monich
f7fa1c81f3 [provision] Fixed memory leak. Contributes to MER#1394
According to valgrind:

543 (8 direct, 535 indirect) bytes in 1 blocks are definitely lost in loss record 413 of 428
   at 0x483F380: malloc (vg_replace_malloc.c:296)
   by 0x4AB6083: g_malloc (gmem.c:104)
   by 0x4ACC9B5: g_slice_alloc (gslice.c:1016)
   by 0x4ACD8A3: g_slist_append (gslist.c:224)
   by 0xCE6BF: gsm_end (mbpi.c:423)
   by 0x4AB470D: g_markup_parse_context_parse (gmarkup.c:1602)
   by 0xCEE03: mbpi_parse (mbpi.c:646)
   by 0xCEEF3: mbpi_lookup_apn (mbpi.c:669)
   by 0xCF453: provision_get_settings (provision.c:184)
   by 0x145E87: __ofono_gprs_provision_get_settings (gprs-provision.c:68)
   by 0x12A983: provision_contexts (gprs.c:3327)
   by 0x12AD1B: spn_read_cb (gprs.c:3413)
2015-11-04 16:41:44 +03:00
Slava Monich
62a0b3518b [provision] Fixed memory leak. Contributes to MER#1394
According to valgrind:

14 bytes in 2 blocks are definitely lost in loss record 155 of 428
   at 0x483F380: malloc (vg_replace_malloc.c:296)
   by 0x4AB6083: g_malloc (gmem.c:104)
   by 0x4ACDAA9: g_strdup (gstrfuncs.c:364)
   by 0xCE383: apn_handler (mbpi.c:329)
   by 0xCE5B3: gsm_start (mbpi.c:386)
   by 0x4AB333B: emit_start_element (gmarkup.c:1029)
   by 0x4AB4685: g_markup_parse_context_parse (gmarkup.c:1366)
   by 0xCEE03: mbpi_parse (mbpi.c:646)
   by 0xCEEF3: mbpi_lookup_apn (mbpi.c:669)
   by 0xCF453: provision_get_settings (provision.c:184)
   by 0x145E87: __ofono_gprs_provision_get_settings (gprs-provision.c:68)
   by 0x12A983: provision_contexts (gprs.c:3327)
2015-11-04 10:58:34 +03:00
Slava Monich
d7cbedc0e9 Merge branch 'jb32969' into 'master'
Don't rely on DATA_CALL_LIST_CHANGED too much

Some RILs don't send `RIL_UNSOL_DATA_CALL_LIST_CHANGED` event after data call gets deactivated, only after activation. Some RILs send it in either case.

Ofono RIL plugin should consider data call disconnected after either `RIL_REQUEST_DEACTIVATE_DATA_CALL` successfully completes or data call disappears from the list reported by `RIL_UNSOL_DATA_CALL_LIST_CHANGED`, whichever happens first. That would work with both kinds of RILs.

See merge request !5
2015-11-04 07:41:21 +00:00
Slava Monich
1e75448127 Merge branch 'addremove' into 'master'
Always fire ModemRemoved first then ModemAdded

When switching from `/ril_1` to `/ril_0` we used to fire `ModemAdded("/ril_0")` followed by `ModemRemoved("/ril_1")` which may confuse D-Bus clients that are not so good at handling multiple modems. To well-behaved clients the order doesn't matter.

See merge request !4
2015-11-04 07:41:03 +00:00
Slava Monich
7ab4da0c91 [ril] Don't rely on DATA_CALL_LIST_CHANGED too much. Fixes JB#32969
Some RILs don't send RIL_UNSOL_DATA_CALL_LIST_CHANGED event after
data call gets deactivated, only after activation. Some RILs send
it in either case.

Ofono RIL plugin should consider data call disconnected after either
RIL_REQUEST_DEACTIVATE_DATA_CALL successfully completes or data call
disappears from the list reported by RIL_UNSOL_DATA_CALL_LIST_CHANGED,
whichever happens first. That would work with both kinds of RILs.
2015-11-03 19:06:48 +03:00
Slava Monich
f13991d04e [ril] Always fire ModemRemoved first then ModemAdded. Contributes to MER#1110
When switching from /ril_1 to /ril_0 we used to fire ModemAdded("/ril_0")
followed by ModemRemoved("/ril_1") which may confuse D-Bus clients that are
not so good at handling multiple modems. To well-bahaved clients the order
doesn't matter.
2015-11-03 16:06:52 +03:00
Slava Monich
c451110c39 [ril] Elimitated dependency on mce-headers. MER#1110
It's just a few defines, not worth the trouble.
2015-11-02 12:08:23 +03:00
Slava Monich
cb9183f3ff Merge branch 'multisim' into 'master'
New RIL plugin supporting multiple modems

Enabled by --enable-jolla-rilmodem configure option. Old plugin is preserved as a reference and for debugging regressions on Jolla1.

See merge request !2
2015-11-02 08:53:27 +00:00
Slava Monich
c1a9d7a578 [ril] New RIL plugin supporting multiple modems. Fixes MER#1110
Enabled by --enable-jolla-rilmodem configure option.
2015-10-30 18:01:37 +03:00
Slava Monich
9aee7ccadd [ofono] Added ofono_gprs_get_roaming_allowed() function
It's required by the RIL modem.
2015-10-25 19:12:17 +03:00
Slava Monich
0777b2853a Merge branch 'log' into 'master'
Allow to specify a function to be called when debug flags change

This allows to pass log level modifications to the external libraries that don't use ofono DBG mechanism.

See merge request !1
2015-10-25 16:09:11 +00:00
Slava Monich
b7bd9ca425 [ofono] Allow to specify a function to be called when debug flags change
This allows to pass log level modifications to the external libraries that
don't use ofono's DBG mechanism.
2015-10-25 18:47:10 +03:00
Marcel Holtmann
8929d131a3 Release 1.17 2015-09-13 17:08:07 +02:00
Slava Monich
97e34cc851 Merge pull request #302 from monich/nettime
Updated nettime plugin to support more than one modem
2015-09-11 17:03:28 +03:00
Slava Monich
e558d48b6f [ofono] Updated nettime plugin to support more than one modem. MER#1110 2015-09-08 22:23:20 +03:00
Alfonso Sanchez-Beato
51fc828c5e sms: Add trace when datagram is not delivered 2015-09-08 09:14:03 -05:00
Alfonso Sanchez-Beato
ac14de37ca smsutil: Do not check the origin port
Do not check if the origin port is reserved, as some operators use that
range of values.
2015-09-08 09:14:03 -05:00
Alfonso Sanchez-Beato
665c053803 push-notification: Accept push from any origin
Accept push notifications regardless of the origin port, as some
operators do not insert there the WAP connectionless session service
port, and use random values instead.
2015-09-08 09:14:03 -05:00
Slava Monich
aca873a5c4 [spec] Fixed configure option. MER#531
Configure option that enables org.ofono.DebugLog interface was misspelled.
2015-08-27 20:59:38 +03:00
Slava Monich
a12e10e36f Merge pull request #301 from monich/uicc_subscription
SET_UICC_SUBSCRIPTION
2015-08-26 12:50:58 +03:00
Slava Monich
7cd3fb74d4 [rilmodem] Simplified RIL initialization code
Requesting SIM status from RIL_REQUEST_SET_UICC_SUBSCRIPTION error handler
smells like a potential infinite loop. And it doesn't seem to be necessary.
Without that, the whole RIL_REQUEST_SET_UICC_SUBSCRIPTION completion
callback becomes unnecessary.

Simplified the algorithm of finding GSM/UMTS app index. It was a bit strange.
2015-08-25 16:37:30 +03:00
Slava Monich
84289d83fd [rilmodem] If error or request code is unknown, print the number
Also added string for RIL_REQUEST_SET_UICC_SUBSCRIPTION
2015-08-25 16:37:02 +03:00
Carsten Munk
f826abdbc7 Implement SET_UICC_SUBSCRIPTION. Fixes MER#1263
This is based on bd4677ee20
and 6b757515bf by Ratchanan Srirattanamet.
Any missing credit, let us know.
2015-08-25 11:28:31 +02:00
Kuba Pawlak
4e9cbcdb89 hfp: Handle extra CCWA event
When a call is waitng, CCWA event is sent and call object
in state WAITING is created. on ReleaseAndAnswer it is
promoted to INCOMING and later to ACTIVE.
iPhones send an extra CCWA event when active call is ended.
This extra event is creating a second call object in state
WAITING. It is not possible to have two WAITING calls, but
previously waiting call was already promoted to INCOMING.
For a brief time we have two calls from the same number,
one INCOMING and one WAITING. Later WAITING one is removed.
As we cannot have a waiting and incoming call at the same
time, ignore CCWA when there is already an INCOMING call.

< \r\n+CIEV: 3,3\r\n
< \r\n+CIEV: 2,1\r\n
< \r\n+CIEV: 3,0\r\n
< \r\n+CCWA: "01234567890",129,1,"Me"\r\n
< \r\n+CIEV: 3,1\r\n
> AT+CLCC\r
< \r\n+CLCC: 1,0,0,0,0,"09876543210",129,"Me"\r\n
< \r\n+CLCC: 2,1,5,0,0,"01234567890",129,"Me"\r\n
< \r\nOK\r\n
< \r\n+CIEV: 2,0\r\n
< \r\n+CCWA: "01234567890",129,1,"Me"\r\n
< \r\n+CIEV: 2,1\r\n
< \r\n+CIEV: 3,0\r\n
> AT+CLCC\r
< \r\n+CLCC: 2,1,0,0,0,"01234567890",129,"Me"\r\n
< \r\nOK\r\n
2015-08-24 16:29:29 -05:00
Slava Monich
f6ac328110 Merge pull request #298 from monich/debuglog
Add org.ofono.DebugLog interface
2015-08-24 14:36:14 +03:00
Slava Monich
8d46ababee [ofono] Added org.ofono.DebugLog interface. MER#531
It provides the following methods:

  array(string,boolean) List()
  void Enable(string pattern)
  void Disable(string pattern)

Enable and Disable methods allow to modify ofono logging settings
without restarting it. The List method returns the list of modules
for which logging can be changed at runtime and their current settings.
2015-08-19 16:33:07 +03:00
Denis Kenzior
9ec8d03c7c voicecall: Don't accept USSD strings in Dial() 2015-08-06 17:16:03 -05:00
Kuba Pawlak
3e6bbc676f hfp: Synchronize call state in case of +CHUP error
It is possible for the phone to accept Dial request
but not actually dial. This leaves a voicecall object
in state 'dialling' that cannot be removed.
Proposed workaround is to trigger AT+CLCC when an error
is returned for Hangup. As the call is not on the list,
this would remove this hanging object and signal CallRemoved.

Windows Phone trace with this fix:
ofonod[273]: > ATD1;\r
ofonod[273]: < \r\nOK\r\n
ofonod[273]: src/voicecall.c:dial_handle_result() Registering new call: 1
ofonod[273]: < \r\n+CIEV: 5,4\r\n
ofonod[273]: src/network.c:ofono_netreg_strength_notify() strength 80
ofonod[273]: > AT+CHUP\r
ofonod[273]: < \r\nERROR\r\n
ofonod[273]: src/voicecall.c:generic_callback() command failed with error: Unknown error type
ofonod[273]: > AT+CLCC\r
ofonod[273]: < \r\nOK\r\n
ofonod[273]: src/voicecall.c:ofono_voicecall_disconnected() Got disconnection event for id: 1, reason: 2
2015-08-05 11:15:33 -05:00
Denis Kenzior
8be0245664 cdma-connman: Make static analysis tools happy
The kernel simply puts a null terminator at index 15 prior to ifr_name
processing.  So we do the same.

Original report by:
Sabas Rosales, Blanca E <blanca.e.sabas.rosales@intel.com>

 Buffer not null terminated (BUFFER_SIZE_WARNING) buffer_size_warning:
 Calling strncpy with a maximum size argument of 16 bytes on destination
 array ifr.ifr_ifrn.ifrn_name of size 16 bytes might leave the
 destination string unterminated.

  92        strncpy(ifr.ifr_name, interface, IFNAMSIZ);
2015-07-28 10:18:26 -05:00
Denis Kenzior
ca105f7040 ppp_net: Make static analysis tools happy
The kernel simply puts a null terminator at index 15 prior to ifr_name
processing.  So we do the same.

Original report by:
Sabas Rosales, Blanca E <blanca.e.sabas.rosales@intel.com>

 Buffer not null terminated (BUFFER_SIZE_WARNING) buffer_size_warning:
 Calling strncpy with a maximum size argument of 16 bytes on destination
 array ifr.ifr_ifrn.ifrn_name of size 16 bytes might leave the
 destination string unterminated.

  67        strncpy(ifr.ifr_name, net->if_name, sizeof(ifr.ifr_name));
2015-07-28 10:16:16 -05:00
Denis Kenzior
dbb3ec13e5 gprs: Try re-attaching when we switch cells 2015-07-20 13:51:29 -05:00
Alfonso Sanchez-Beato
1b3302322a message-waiting: Fix reading EF_MWIS records 2015-07-16 20:22:38 -05:00
Alfonso Sanchez-Beato
cd76f913f0 message-waiting: Update properly EF_MWIS SIM file 2015-07-16 20:17:27 -05:00
Denis Kenzior
8dc220bc11 AUTHORS: Mention Johannes' contributions 2015-07-16 14:11:14 -05:00
Johannes 'josch' Schauer
b04fabcda3 udevng: add support for Ericsson N5321 gw 2015-07-16 14:10:41 -05:00
Kuba Pawlak
71df8bb15e hfp_hf_bluez5: Fix crash on re-pairing a Device
It may happen that a Device object is unpaired an paired again
without being removed from DBus. This in turn triggers second
modem object to be created, but not fully initialized.
If this modem object is used, oFono will crash.
2015-07-12 21:19:31 -05:00
Denis Kenzior
35ebbf4c97 handsfree: Mark GetProperties method ASYNC 2015-07-06 04:06:45 -05:00
Marcel Holtmann
a2acb227fd u8500: Fix compiler warning with logical expression
CC       plugins/u8500.o
plugins/u8500.c: In function ‘reachable_cb’:
plugins/u8500.c:235:28: error: logical not is only applied to the left hand side of comparison [-Werror=logical-not-parentheses]
  if (!g_isi_msg_error(msg) < 0)
                            ^
2015-07-07 11:35:54 +02:00
Marcel Holtmann
def77f7653 n900: Fix compiler warning with logical expression
CC       plugins/n900.o
plugins/n900.c: In function ‘mtc_reachable_cb’:
plugins/n900.c:241:28: error: logical not is only applied to the left hand side of comparison [-Werror=logical-not-parentheses]
  if (!g_isi_msg_error(msg) < 0)
                            ^
2015-07-07 11:35:54 +02:00
Marcel Holtmann
c3af639874 isiusb: Fix compiler warning with logical expression
CC       plugins/isiusb.o
plugins/isiusb.c: In function ‘reachable_cb’:
plugins/isiusb.c:207:28: error: logical not is only applied to the left hand side of comparison [-Werror=logical-not-parentheses]
  if (!g_isi_msg_error(msg) < 0)
                            ^
2015-07-07 11:35:54 +02:00
Marcel Holtmann
b2b67fa74e gatchat: Fix compiler warning with logical expression
CC       gatchat/gatchat.o
gatchat/gatchat.c: In function ‘have_line’:
gatchat/gatchat.c:586:28: error: logical not is only applied to the left hand side of comparison [-Werror=logical-not-parentheses]
  if (!strncmp(str, "AT", 2) == TRUE)
                            ^
2015-07-07 11:35:54 +02:00
Denis Kenzior
96754c0dfc AUTHORS: Mention Marko's contributions 2015-07-05 05:44:46 -05:00
Marko Sulejic
f2c474c55a configure.ac: fix typo 2015-07-05 05:43:56 -05:00
Slava Monich
07144c2dd5 Merge pull request #294 from monich/mer1137
Don't drop SMS datagrams with unknown ports
2015-07-02 00:57:27 +03:00
Denis Kenzior
58076d9a00 AUTHORS: Mention Sergey's contributions 2015-07-01 08:10:39 -05:00
Sergey Alirzaev
4a937b96aa build: make ofono build against musl
ifdef away GNU libc extensions and use a POSIXly correct pointer type
2015-07-01 08:09:53 -05:00
Denis Kenzior
fceb5a41c2 handsfree: Fix potential buffer overflow
Function: ag_features_list
 static const char *list[10];  (Out of bounds write, line 75)
  Incrementing i the value is now 10, for “hf-indicators”

Reported by: blanca.e.sabas.rosales@intel.com
2015-06-30 16:58:36 -05:00
Slava Monich
0073dc7bfc [sms] Don't drop SMS datagrams with unknown ports. Fixes MER#1137 2015-06-26 15:52:35 +03:00
Tommi Kenakkala
297bdaba0f Merge pull request #293 from tkenakka/cherrypick-pin-upstr
[sim] Improve Emit LockedPins after pin_type is queried. MER#1082
2015-06-23 15:12:46 +03:00
Tommi Kenakkala
f14db3b2a6 Merge pull request #292 from tkenakka/sockpath
Read RILD command socket path from a conf file. MER#1107
2015-06-23 14:44:31 +03:00
Tommi Kenakkala
4a0182616d [ril] Read RILD socket path from a file at startup. MER#1107
This allows configuring at startup the socket path to which ril plugin
will connect to.
2015-06-23 11:44:48 +03:00
Tommi Kenakkala
bbdfc8f46d [sim] Improve Emit LockedPins after pin_type is queried. MER#1082
Merge additional upstreaming changes from upstream commit eebe2f3
to previous nemomobile ofono commit 10328e6
2015-06-23 11:38:10 +03:00
Tommi Kenakkala
fbd59a8dc9 [gril] Change oFono gril to take a socket path. MER#1107
This allows configuring at startup the socket path to which gril
will connect to.
2015-06-22 11:16:00 +03:00
Denis Kenzior
48da783732 sim: Fix up whitespace issues 2015-06-18 14:59:06 -05:00
Tommi Kenakkala
eebe2f3ac2 Emit LockedPins after pin_type is queried
Fixes property change not being emited when hot-swapping a
PIN-enabled card.
2015-06-18 14:56:05 -05:00
Tommi Kenakkala
7eb6d5559a Merge pull request #291 from tkenakka/pin
[sim] Reset ofono pin state to none when card removed
2015-06-18 12:14:18 +03:00
Tommi Kenakkala
9a47510eb5 [sim] Coding conventions improvements for sim.c
Improves 10328e626d
2015-06-18 12:11:03 +03:00
Tommi Kenakkala
8fc7ae836f [sim] Reset pin state to none when card removed
Improves d88af05dc3
sim_get_properties would have problems with OFONO_SIM_PASSWORD_INVALID.
2015-06-18 12:11:03 +03:00
Tommi Kenakkala
4677729502 sim: Reset pin_type on card remove
Fixes PinRequired not being emitted when a card is inserted
2015-06-17 23:09:03 -05:00
Tommi Kenakkala
8c0f4f27eb Merge pull request #290 from tkenakka/pin
Refactor rilmodem SIM PIN handling
2015-06-10 15:09:53 +03:00
Tommi Kenakkala
b932bed519 Merge pull request #288 from monich/features
Don't unnecessarily emit "Features" PropertyChanged signal
2015-06-10 15:08:34 +03:00
Tommi Kenakkala
db83ac369b Merge pull request #287 from monich/leak
Fix memory leak
2015-06-10 15:02:54 +03:00
Tommi Kenakkala
e26df8a645 [rilmodem] Minor sim related logging updates 2015-06-09 16:19:01 +03:00
Tommi Kenakkala
5144f3fa14 [rilmodem] Remove ofono_set_pin_lock_state. Contributes MER#1082
Core sets LockedPins when driver returns that a PIN query is
required.
2015-06-09 16:17:55 +03:00
Tommi Kenakkala
0d6459b9b0 [sim] Remove ofono_set_pin_lock_state. Contributes MER#1082 2015-06-09 16:17:44 +03:00
Tommi Kenakkala
10328e626d [sim] Emit LockedPins changed. Contributes MER#1082
org.ofono.SimManager "Present" is signalled by ofono_sim_inserted_notify,
but LockedPins and PinRequired are updated later by sim_pin_query_cb.
Without signalling a client does not know when LockedPins
becomes available.
2015-06-09 16:05:43 +03:00
Tommi Kenakkala
5b407d654a [rilmodem] Reset retry count on PIN state change
After this rilmodem driver reports retries only for the required PIN type
and does not remember counts for previous password types.
2015-06-09 16:05:43 +03:00
Tommi Kenakkala
d88af05dc3 [sim] Reset pin_type on card removal. Contributes MER#1083
With this the variable behind org.ofono.SimManager "PinRequired"
is reset when card is removed, allowing signalling property change
in sim_pin_query_cb when card is inserted back.
2015-06-09 16:05:43 +03:00
Tommi Kenakkala
99cae6876f [rilmodem] Reset rilmodem driver's PIN type on card removal. Contributes MER#1083
Getting the PIN state for a freshly inserted card takes a while,
without this change driver uses the old state until the new state
is known.
2015-06-09 16:05:43 +03:00
Tommi Kenakkala
89e6593f9c [rilmodem] Delay signalling SIM inserted until PIN state available
Delay ofono_sim_inserted_notify call to core until PIN state is parsed
from gsmumts application by rilmodem driver.
2015-06-09 16:05:43 +03:00
Kuba Pawlak
93ccb84761 hfpmodem: Fix connecting to AG with existing mpty
If there is more then one active or held call, we are in mpty calls.
We won't get indicator update if any of them is released by CHLD=1x.
So we have to poll it.
2015-06-04 16:18:08 -05:00
Alfonso Sanchez-Beato
e70afdd9dc gprs: Add comment to gprs_reset_contexts 2015-05-18 12:13:04 -05:00
Denis Kenzior
1edb6eec9b test: Fix file mode for reset-contexts 2015-05-18 10:02:10 -05:00
Alfonso Sanchez-Beato
946b568f43 gprs: Refactor to remove forward declaration 2015-05-18 09:08:33 -05:00
Alfonso Sanchez-Beato
f3f3dabfac test: Add script for resetting contexts 2015-05-18 09:08:28 -05:00
Alfonso Sanchez-Beato
4c0f783f5c doc: Add description for ResetContexts method 2015-05-18 09:08:20 -05:00
Alfonso Sanchez-Beato
444611c086 gprs: Add DBus method to reset contexts
Add DBus method that removes the current contexts and re-provisions
using the APN database.
2015-05-18 09:08:13 -05:00
Tommi Kenakkala
8e9085f5ab Merge pull request #289 from tkenakka/simmgr
[rilmodem] Fix simmanager removal handling. Contributes to MER#928
2015-05-15 12:47:15 +03:00
Tommi Kenakkala
c33a48ea0c [rilmodem] Fix simmanager removal handling. Contributes to MER#928
Improves 7d0d72a.
2015-05-15 11:38:21 +03:00
Alex J Lennon
f8d9485dc2 cinterion: Correct use of freed structure
On error struct cb_data *cbd was used after in cinterion_set_online
after already being freed.
2015-05-13 15:56:34 -05:00
Denis Kenzior
23c45abd57 ste: Fix out-of-order free
CALLBACK_WITH_FAILURE used data structure freed just beforehand
2015-05-13 15:55:00 -05:00
Denis Kenzior
a371f46735 dundee: Fix out-of-order free
CALLBACK_WITH_FAILURE used data structure freed just beforehand
2015-05-13 15:44:39 -05:00
Denis Kenzior
ce0529fcf6 AUTHORS: Mention Alex's contributions 2015-05-13 09:57:53 -05:00
Alex J Lennon
fc3f937a67 udev: Add support for ehs6 name
As with tc65, ehs6 makes use of cinterion plugin
2015-05-13 09:57:53 -05:00
Alex J Lennon
7d4a19b114 cinterion: Register as OFONO_VENDOR_CINTERION
This enables us to take advantage of vendor specific quirks
(e.g. signal strength handling specifics for tc65)
2015-05-13 09:57:53 -05:00
Alex J Lennon
4242f6ee72 atmodem: Add Cinterion quirk for signal strength
Implement OFONO_VENDOR_CINTERION specific vendor support to register
textual +CIEV indications for signal strength using AT^SIND command.
2015-05-13 09:57:53 -05:00
Alex J Lennon
b31a3c2390 tc65: Replace tc65 plugin with cinterion plugin
On the basis that tc6x and other Cinterion devices will likely
have similar firmware requirements, provide a generic Cinterion
plugin which is functionally identical to the replaced tc65 plugin.

The udev implementation retains support for "tc65" name for
backwards compatibility, and adds support for the new "cinterion"
name.
2015-05-13 09:57:53 -05:00
Denis Kenzior
8d47f97106 hfp_hf_bluez5: Implement sco_connected_hint 2015-05-13 09:57:53 -05:00
Denis Kenzior
fdba39b8ed handsfree-audio: Call sco_connected_hint 2015-05-13 09:57:52 -05:00
Denis Kenzior
288364295c include: Add sco_connected_hint to handsfree-audio 2015-05-13 09:57:52 -05:00
Denis Kenzior
bce5d9579c gatchat: Introduce g_at_chat_get_userdata 2015-05-13 09:57:52 -05:00
Denis Kenzior
1c2987670d handsfree-audio: Add additional debugs 2015-05-13 09:57:52 -05:00
Tommi Kenakkala
44585697c3 Merge pull request #286 from tkenakka/simmgr
Register SimManager interface always and simplify logic
2015-05-06 10:06:29 +03:00
Slava Monich
3860230644 [modem] Don't unnecessarily emit "Features" PropertyChanged signal
Not all interfaces have corresponding features, meaning that not every
interface addition or removal actually updates the feature list.
If nothing else, this reduces the number of D-Bus signals emitted.
2015-05-05 16:11:06 +03:00
Tommi Kenakkala
07da2f3fa7 [rilmodem] Minor updates to error debug logging
Added function name prefix printing.
2015-05-05 15:52:35 +03:00
Tommi Kenakkala
7d0d72a4a9 [rilmodem] Register SimManager always and simplify logic. MER#928
Register org.ofono.SimManager always, without this the dbus
interface does not exist when starting without a SIM card.
Simplified rilmodem SIM status handling.
Moved some debug logging from sim.c to rilutil.c.
2015-05-05 15:52:35 +03:00
Tommi Kenakkala
f9ee2ae9b8 [rilmodem] Remove rilplugin sim inserted notification. MER#928
Functionality combined in rilmodem/sim.c.
No need to notify from both ril.c and sim.c.
2015-05-05 15:52:35 +03:00
Slava Monich
063234a433 [rilmodem] Fixed memory leak in handle_sne() 2015-05-05 15:51:12 +03:00
Tommi Kenakkala
c006d822f1 [rilmodem] Improve rilutil debug logging
Move some logs from rilmodem/sim.c to rilmodem/rilutil.c
and do some additional improvements.
2015-04-30 16:17:12 +03:00
Luiz Augusto von Dentz
a5b040b781 gdbus: Close private connection if setup fails
Private connection should be properly closed with dbus_connection_close
otherwise libdbus exits with the following error:

  'The last reference on a connection was dropped without closing the
   connection. This is a bug in an application. See
   dbus_connection_unref() documentation for details. Most likely, the
   application was supposed to call dbus_connection_close(), since this
   is a private connection.'
2015-04-20 09:04:39 +02:00
Szymon Janc
97abe1751d gdbus: Fix crash in g_dbus_create_error_valist
Passing NULL format parameter to vsnprintf results in invalid argument
error on glibc. But with some other libc libraries (musl and uClibc)
this results in dereferencing NULL pointer and crash due to
segmentation fault.
2015-04-09 16:59:08 +02:00
Szymon Janc
2f75b13ecd gdbus: Use g_dbus_create_error_valist internally
There is no need to duplicate code in g_dbus_send_error_valist.
2015-04-09 16:59:08 +02:00
Michael Janssen
73e517bcca gdbus: Add g_dbus_get_flags function
The g_dbus_get_flags function enables detection of when the
G_DBUS_FLAG_ENABLE_EXPERIMENTAL is set.
2015-04-07 19:00:45 +02:00
Luiz Augusto von Dentz
dae225a0d6 gdbus: Make GDBusClient work without ObjectManager
This makes GDBusClient work normally without ObjectManager.
2015-03-26 10:02:05 +01:00
Arman Uguray
97ac3f7c76 gdbus/client: Allow specifying ObjectManager path
GDBusClient currently hard-codes "/" as the remote ObjectManager path.
This is generally incorrect, as an application can choose to expose an
ObjectManager at any well-known path. This patch fixes this by allowing
the user to pass in the ObjectManager path by introducing a new
conctructor "g_dbus_client_new_full".
2015-03-26 10:02:05 +01:00
Arman Uguray
26a00f2f31 gdbus/client: Don't GetManagedObjects w/o handlers
The client code currently issues GetManagedObjects if new handlers are
set via g_dbus_client_set_proxy_handlers. An application may set these
to NULL before unref'ing a client or to simply prevent further events.
Hence, there is no need to refresh objects or properties if all handlers
are NULL.
2015-03-26 10:02:05 +01:00
Kuba Pawlak
cede3700f7 hfpmodem: slc.c: make sure to use none_prefix 2015-03-24 11:05:03 -05:00
Kuba Pawlak
318d313fc9 hfpmodem: hfpmodem.c make sure to use none_prefix 2015-03-24 11:04:48 -05:00
Kuba Pawlak
8e6ebab83b hfp_ag_bluez5: use none prefix for AT+BCC.
iPhone 5s with iOS8.2 sometimes failes to acknowledge AT+BCC
with OK. This means +CIEV events get consumed by this command
and call ended notification is not parsed.

Nov 30 00:00:19 ofonod[938]: > AT+BCC\r
Nov 30 00:00:28 ofonod[938]: < \r\n+CIEV: 2,0\r\n
2015-03-24 09:12:58 -05:00
Tommi Kenakkala
7331c88b41 Merge pull request #285 from tkenakka/merge1.16
Merge oFono upstream release 1.16
2015-03-04 13:48:08 +02:00
Tommi Kenakkala
063eefbac1 [ofono] Disable build time he910 modem 2015-03-03 15:27:45 +02:00
Tommi Kenakkala
12b510b4e7 [ofono] Update version to 1.16 2015-03-03 15:27:38 +02:00
Tommi Kenakkala
c04f5df8ec [ofono] Merge upstream release 1.16 2015-02-27 15:56:55 +02:00
Tommi Kenakkala
011bc0741a Merge pull request #284 from tkenakka/master
[gprs] Fix pri_reset_context_properties crashes
2015-02-27 11:36:09 +02:00
Tommi Kenakkala
773834c5a3 [gprs] Fix pri_reset_context_properties crashes
Fixes issues of ff63e9b0
2015-02-27 11:08:03 +02:00
Tommi Kenakkala
14acafc581 Merge pull request #283 from tkenakka/norild
Rild comms socket detection and monitoring for oFono rilmodem plugin
2015-02-26 13:29:32 +02:00
Tommi Kenakkala
b4df40608b [gril] Minor updates to ofono gril logging 2015-02-26 11:52:24 +02:00
Tommi Kenakkala
26f750fe4f [plugins] Improved ofono rilmodem socket handling
- Fix rildev.c's rild socket inotify handling
- Fix gril creation fail handling
- Improve logic logging and add __func__ arg for some ofono_XXX log prints
- Same style for rildev plugin name descriptor as what rilmodem plugin has
2015-02-26 11:52:23 +02:00
Jarko Poutiainen
51f6837545 [plugins] rildev.c remove unnecessary modem reset
Signed-off-by: Jarko Poutiainen <jarko.poutiainen@oss.tieto.com>
2015-02-25 15:18:52 +02:00
Jarko Poutiainen
6919c43ff6 [plugins] rildev.c add error handling
Signed-off-by: Jarko Poutiainen <jarko.poutiainen@oss.tieto.com>
2015-02-25 15:18:52 +02:00
Jarko Poutiainen
621614e518 [Makefile] add rildev as builtin
Signed-off-by: Jarko Poutiainen <jarko.poutiainen@oss.tieto.com>
2015-02-25 15:18:52 +02:00
Jarko Poutiainen
8e820dfdd3 [gril] gril.h remove current_passwd
Signed-off-by: Jarko Poutiainen <jarko.poutiainen@oss.tieto.com>
2015-02-25 15:18:51 +02:00
Jarko Poutiainen
04cc2e9fd2 [gril] gril.c remove current_passwd
Signed-off-by: Jarko Poutiainen <jarko.poutiainen@oss.tieto.com>
2015-02-25 15:18:51 +02:00
Jarko Poutiainen
ae5c8e6e3a [rilmodem] remove current_passwd support from sim driver
Signed-off-by: Jarko Poutiainen <jarko.poutiainen@oss.tieto.com>
2015-02-25 15:18:51 +02:00
Jarko Poutiainen
1509cb811a [plugins] ril to support rild socket detection
Signed-off-by: Jarko Poutiainen <jarko.poutiainen@oss.tieto.com>
2015-02-25 15:18:51 +02:00
Jarko Poutiainen
5682df6d82 [plugins] rildev to detect rild socket
Signed-off-by: Jarko Poutiainen <jarko.poutiainen@oss.tieto.com>
2015-02-25 15:18:51 +02:00
Jarko Poutiainen
3e38512e2f [plugins] add rildev.h
Signed-off-by: Jarko Poutiainen <jarko.poutiainen@oss.tieto.com>
2015-02-25 15:18:51 +02:00
Alfonso Sanchez-Beato
dc5157c5d0 plugins: Add rildev for creation of ril modems
This new plugin will create ril modems, providing the same
functionality as udev/udevng does for USB-based modems.
2015-02-25 15:18:51 +02:00
Tommi Kenakkala
59449f74a1 Merge pull request #282 from monich/provision
Add ProvisionContext method to ConnectionContext interface
2015-02-25 15:16:31 +02:00
Slava Monich
ff63e9b057 [ofono] Added ProvisionContext method to ConnectionContext interface
Allows to reset connection context properties back to default.
2015-02-25 12:36:04 +02:00
Szymon Janc
d8edd49535 gdbus: Fix not calling disconnect function
If daemon gets disconnected from D-Bus sender is NULL. Watches that
was explicitly added with NULL sender (ie disconnected_signal in
g_dbus_set_disconnect_function) should be called anyway.
2015-02-24 18:24:42 +01:00
Pasi Sjöholm
7b73f569eb Merge pull request #280 from tigeli/master
[rilmodem] fix issue with only one nameserver being provided
2015-02-23 10:03:55 +01:00
Arman Uguray
8660527b11 gdbus: Don't refresh objects/props if disconnected
If g_dbus_client_set_proxy_handlers gets called from within a
proxy_removed callback, the code may end up refreshing the proxy's
properties and incorrectly access the client's proxy_list as it gets
freed. This patch fixes this, so that get_managed_objects does nothing
if it gets called during a service disconnect.
2015-02-22 19:42:25 +01:00
Pasi Sjöholm
5672f7248d [rilmodem] fix issue with only one nameserver being provided
No need to check if we have multiple nameserver provided
by the context, single one is enough.
2015-02-20 22:21:26 +02:00
Denis Kenzior
d6bc91ebfc hfpmodem: Make sure to use none_prefix
ofonod[253]: > AT+CCWA=1\r
ofonod[253]: < \r\n+BCS:2\r\n
ofonod[253]: < \r\nOK\r\n
2015-02-20 10:30:21 -06:00
Denis Kenzior
3d592d7d46 hfpmodem: Make sure to set the prefix properly
ofonod[1239]: > AT+COPS=3,0\r
ofonod[1239]: < \r\n+BCS:2\r\n
ofonod[1239]: < \r\nOK\r\n
2015-02-20 10:28:24 -06:00
Tommi Kenakkala
2ed0073bd1 Merge pull request #279 from tkenakka/log
[ofono] Add ril disconnect logging
2015-02-17 12:29:19 +02:00
Tommi Kenakkala
f6ade48648 Merge pull request #278 from tkenakka/sms-tp-oa
Fix received SMS alphanumeric TP-OA handling
2015-02-17 12:28:55 +02:00
Tommi Kenakkala
73ba48c9fb [ofono] Add ril disconnect logging 2015-02-17 11:12:18 +02:00
Tommi Kenakkala
f3611cef21 [ofono] unit: Add test to encode / decode 11 char SMS TP-OA 2015-02-16 10:31:16 +02:00
Tommi Kenakkala
15d682e62a [ofono] sms: Fix alphanumeric TP-OA handling
This fixes the issue of ofono ignoring received SMS if originator address
is a 11-character long alphanumeric string (with ext. ASCII).

TP-OA max length comparisons were incorrect because TP-OA's 7-bit coded
octets transport eleven 8-bit chars. The current code assumed only 10 chars
were possible.
- increases the array size to 23, (max 22 bytes for UTF8 + null terminator)
- Updates the sanity check to account for the correct maximum
- For encoding, checks the maximum length in UTF8 characters instead of bytes
- Make sure after the UTF8 -> GSM conversion that the number of GSM bytes is
not > 11, which is the maximum payload.
2015-02-16 10:30:18 +02:00
Denis Kenzior
e2398b4dfa smsutil: Add additional sanity check
We make sure that after performing the UTF8 -> GSM conversion, the
number of GSM bytes is not greater than 11, which is the maximum
payload.
2015-02-13 09:59:59 -06:00
Tommi Kenakkala
42deee76a1 unit: Add test to encode / decode 11 char TP-OA 2015-02-13 09:55:16 -06:00
Tommi Kenakkala
2af3c733b7 sms: Fix alphanumeric TP-OA handling
TP-OA max length comparisons were incorrect because TP-OA's 7-bit
coded octets transport eleven 8-bit chars.  The current code assumed
only 10 chars were possible.

The patch
- increases the array size to 23, (maximum of 22 bytes for UTF8
  encoding + null terminator)
- Updates the sanity check to account for the correct maximum
- For encoding, checks the maximum length in UTF8 characters instead of
  bytes
2015-02-13 09:49:39 -06:00
Denis Kenzior
604fa223f4 AUTHORS: Mention Tommi's contributions 2015-02-02 09:29:46 -06:00
Tommi Kenakkala
04218d3a86 handsfree-audio: Refactor manager init / cleanup 2015-02-02 09:28:34 -06:00
Tommi Kenakkala
41fadd3787 main: Remove handsfree_audio_manager init/cleanup
Init allocates a SCO audio socket always. oFono should do that
with bluez5 but not with bluez4.  This patch starts the refactoring of
the handsfree_audio_manager init/cleanup functionality.
2015-02-02 09:26:58 -06:00
Cedric Jehasse
d539ed19f3 atmodem: fix retries reporting from AT+CPINR
The retries array was not correctly filled in.
2015-02-02 09:22:21 -06:00
Cedric Jehasse
25f926c733 atmodem: Sierra modems should be polled after CPIN
Sierra modem will return "CME ERROR: 14" when polled right after pin has
been entered. Use the existing vendor quirk to handle this.
2015-02-02 09:21:10 -06:00
Cedric Jehasse
151b837428 sierra: add sim state polling after CFUN enable
When pin is queried shortly after a Siera dongle is plugged in,
"AT+CPIN?" responds with "CME ERROR 14: SIM".
Poll the sim, as already done by several other vendor plugins.
2015-01-31 10:20:18 -06:00
Tommi Kenakkala
0c23ed90b7 Merge pull request #276 from tkenakka/sco-sock
[ofono] hfp_hf_bluez5 typo fix
2015-01-27 10:44:12 +02:00
Tommi Kenakkala
54854c44a2 [ofono] hfp_hf_bluez5 typo fix 2015-01-27 10:41:00 +02:00
Tommi Kenakkala
da297d5722 Merge pull request #275 from tkenakka/sco-sock
[ofono] Move handsfree audio manager cleanup to hfp_hf_bluez5 plugin
2015-01-27 10:34:12 +02:00
Tommi Kenakkala
aba76cec73 [ofono] Move handsfree audio manager cleanup to hfp_hf_bluez5 plugin 2015-01-27 10:02:40 +02:00
Tommi Kenakkala
3cdc8f775d Merge pull request #274 from tkenakka/sco-sock
[ofono] Move SCO socket allocation to hfp_hf_bluez5 plugin
2015-01-27 09:02:20 +02:00
Tommi Kenakkala
bee03f8b56 [ofono] Move SCO socket allocation to hfp_hf_bluez5 plugin
SCO socket is handled by Bluez4 and conflicts with ofono's socket
allocation.
2015-01-27 08:58:48 +02:00
Tommi Kenakkala
7f4da6d59f Merge pull request #273 from jpoutiai/signal-context
Emit signal when context changed
2015-01-13 09:17:30 +02:00
Tommi Kenakkala
5754fff800 Merge pull request #272 from monich/noproxy
Setup route for mmsc if there's no mms proxy
2015-01-07 16:05:02 +02:00
Jarko Poutiainen
fff6952703 [rilmodem] if data call changed emit signal
Signed-off-by: Jarko Poutiainen <jarko.poutiainen@oss.tieto.com>
2015-01-07 09:44:06 +02:00
Jarko Poutiainen
96ff96ab1a [gril] compare data call lists based on cid
Signed-off-by: Jarko Poutiainen <jarko.poutiainen@oss.tieto.com>
2015-01-07 09:43:43 +02:00
Jarko Poutiainen
986ac50b9e [gril] publish g_ril_unsol_cmp_dcl
Signed-off-by: Jarko Poutiainen <jarko.poutiainen@oss.tieto.com>
2015-01-07 09:43:10 +02:00
Jarko Poutiainen
8600d8d293 [gprs] implement ofono_gprs_context_signal_change
Signed-off-by: Jarko Poutiainen <jarko.poutiainen@oss.tieto.com>
2015-01-07 09:42:52 +02:00
Jarko Poutiainen
369af1b401 [gprs] define ofono_gprs_context_signal_change
Signed-off-by: Jarko Poutiainen <jarko.poutiainen@oss.tieto.com>
2015-01-06 13:08:28 +02:00
Slava Monich
500b5234b2 [gprs] Setup route for mmsc if there's no mms proxy 2015-01-05 15:56:12 +03:00
Slava Monich
93eb292b75 Merge pull request #271 from monich/OperatorsChanged
Add NetworkRegistration.OperatorsChanged signal
2014-12-31 12:47:57 +03:00
Slava Monich
3cc42fb087 [network] Added NetworkRegistration.OperatorsChanged signal
This signal gets emitted when operator list has changed.
It contains the current list of operators.
2014-12-22 09:12:18 +01:00
Marcel Holtmann
c9e426ecd7 Release 1.16 2014-12-13 02:56:19 +01:00
Alfonso Sanchez-Beato
10f173981c radio-settings: Show all available technologies
Not all possible futures technologies were being showed on the DBus
interface.
2014-12-12 08:54:14 -06:00
Jarko Poutiainen
782f2327fd Merge pull request #270 from jpoutiai/ipv6
[RILMODEM] fix same gateway for ipv4 and ipv6 issue
2014-12-12 12:38:26 +02:00
Tommi Kenakkala
8bda4032ca Merge pull request #269 from tkenakka/master
[rilmodem] Log ril version
2014-12-12 10:40:53 +02:00
Tommi Kenakkala
b2f4bd7603 [rilmodem] Log ril version 2014-12-12 10:22:11 +02:00
Jarko Poutiainen
33bb6d829c [RILMODEM] fix same gateway for ipv4 and ipv6 issue
Signed-off-by: Jarko Poutiainen <Jarko.Poutiainen@oss.tieto.com>
2014-12-12 08:32:38 +02:00
Denis Kenzior
bb71141d79 phonesim: Instantiate radio-settings in post_sim 2014-12-10 11:03:17 -06:00
Denis Kenzior
4e466f6fec phonesim: Add minimal radio-settings functionality 2014-12-10 11:03:17 -06:00
Denis Kenzior
a89f8cd56d phonesim: Add skeleton of radio settings driver 2014-12-10 11:03:16 -06:00
Denis Kenzior
95482cb84a radio-settings: Always query available rats
If fast dormancy query is not implemented the available rats are not
queried.
2014-12-10 11:03:16 -06:00
Denis Kenzior
fce95b767a radio-settings: Add additional sanity check 2014-12-10 11:03:16 -06:00
Denis Kenzior
44049f064a radio-settings: rework AvailableTechnologies logic
Take advantage of the new enum structure to future proof and simplify
the logic of generating the AvailableTechnologies property
2014-12-10 11:03:16 -06:00
Denis Kenzior
b899f4aca2 include: No need for OFONO_FLAG* defines 2014-12-10 11:03:16 -06:00
Alfonso Sanchez-Beato
e1cbc5c5ea test: Add AvailableTechnologies to list-modems 2014-12-10 11:03:16 -06:00
Alfonso Sanchez-Beato
5210b85c22 src: Implement RAT list property 2014-12-10 11:03:16 -06:00
Alfonso Sanchez-Beato
e6048f1dc1 include: Add method to list RATs to radio-settings 2014-12-10 11:03:16 -06:00
Tommi Kenakkala
1bea99ac56 Merge pull request #267 from jpoutiai/ipv6
Ipv6
2014-12-10 13:46:16 +02:00
Alfonso Sanchez-Beato
6bdc109ec0 doc: Add AvailableTechnologies property
This new property in org.ofono.RadioSettings interface will hold the
possible values for radio access technology for the modem.
2014-12-09 22:29:21 -06:00
Jarko Poutiainen
aab24b3f24 Merge pull request #268 from hedayat/master
Re-enable CBS in n900 plugin and fix CBS related crash in N9
2014-12-09 07:47:42 +02:00
Jarko Poutiainen
65eea56efe [RILMODEM] use glib to split string to array and some style fixes
Signed-off-by: Jarko Poutiainen <Jarko.Poutiainen@oss.tieto.com>
2014-12-08 15:54:55 +02:00
Jarko Poutiainen
8ac7e502b7 [GRIL] use glib to split string to array
Signed-off-by: Jarko Poutiainen <Jarko.Poutiainen@oss.tieto.com>
2014-12-08 15:53:06 +02:00
Hedayat Vatankhah
9e8bdf0d64 [packaging] Fix error in changelog date format preventing mb2 builds 2014-12-08 01:46:41 +03:30
Hedayat Vatankhah
70e99152a3 Fix cbs related n900/isimodem crash
Don't remove cbs data during shutdown sequence in isimodem driver, since
it is already being removed.

[n900] Fix cbs related crash
2014-12-08 01:46:41 +03:30
Hedayat Vatankhah
a90fc92665 Revert "Remove the cbs creation for n900 plugin, this lead to crashes on n9 ofono init."
This reverts commit 804bef98ad.
2014-12-08 01:46:41 +03:30
Denis Kenzior
7dca0a7315 sim: Fix pin retries bogus values on some arch-es
On some architectures the SimManager.Retries property was getting bogus
values.  This is because we were sending an array which pointed to int
values instead of the expected unsigned char values.

This fix allocates a temporary array of unsigned chars to hold the
actual D-Bus values being sent.  Additionally, the dictionary array is
changed to point to the temporary unsigned char based values instead of
the raw 'int' based retry values.
2014-12-04 08:57:48 -06:00
Jarko Poutiainen
1d23793eb0 Merge pull request #266 from locusf/master
Remove the cbs creation for n900 plugin, this lead to crashes on n9 ofon...
2014-12-01 07:58:33 +02:00
Aleksi Suomalainen
804bef98ad Remove the cbs creation for n900 plugin, this lead to crashes on n9 ofono init.
For the latest release of ofono for Nemo Mobile, the modem fails to initialize
with the isimodem driver enabled. This is due to a segmentation fault occurring
in the flush of the atoms of the modem in cbs_assembly_free function. This
resulted in a segmentation fault when using n900 driver.

[n900] Remove cbs creation.
2014-11-30 16:06:58 +00:00
Jarko Poutiainen
1fdde8fecb [RILMODEM] gprs dual mode support
Signed-off-by: Jarko Poutiainen <Jarko.Poutiainen@oss.tieto.com>
2014-11-26 14:38:06 +02:00
Jarko Poutiainen
1c484a6d04 [GRIL] in reply parse all datacall settings
Signed-off-by: Jarko Poutiainen <Jarko.Poutiainen@oss.tieto.com>
2014-11-26 13:55:13 +02:00
Neil Jerram
19519b2132 test: Support receiving SMS with non-ASCII chars
Without this I get the following Python traceback, for an SMS that
contains the UK pound sign.

ERROR:dbus.connection:Exception in handler for D-Bus signal:
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/dbus/connection.py", line 230, in maybe_handle_message
    self._handler(*args, **kwargs)
  File "./receive-sms", line 9, in incoming_message
    print("%s" % (message))
UnicodeEncodeError: 'ascii' codec can't encode character u'\xa3' in position 51: ordinal not in range(128)
2014-11-24 12:29:45 -06:00
Jarko Poutiainen
64e888ef04 [RILMODEM] ipv6 support
Signed-off-by: Jarko Poutiainen <Jarko.Poutiainen@oss.tieto.com>
2014-11-20 09:54:33 +02:00
Jarko Poutiainen
b33e0061d0 Merge pull request #263 from jpoutiai/sim-fix
[RILMODEM] fix hotswap regression
2014-11-18 15:27:29 +02:00
Jarko Poutiainen
2babf82823 [RILMODEM] fix hotswap regression
Signed-off-by: Jarko Poutiainen <Jarko.Poutiainen@oss.tieto.com>
2014-11-18 14:10:20 +02:00
Jarko Poutiainen
87a35d5d83 Merge pull request #262 from nemomobile-packages/no-fake
No fake
2014-11-17 15:48:17 +02:00
Jarko Poutiainen
3d264276de [RILMODEM] style fixes
Signed-off-by: Jarko Poutiainen <Jarko.Poutiainen@oss.tieto.com>
2014-11-17 15:31:51 +02:00
Jarko Poutiainen
d6bd24add3 [RILMODEM] remove gprs state faking
Signed-off-by: Jarko Poutiainen <Jarko.Poutiainen@oss.tieto.com>
2014-11-13 10:33:55 +02:00
Jarko Poutiainen
9624eb9ace [gprs] publish ofono_gprs_get_modem
Signed-off-by: Jarko Poutiainen <Jarko.Poutiainen@oss.tieto.com>
2014-10-31 14:55:08 +02:00
Jarko Poutiainen
14672319d2 [gprs] implement ofono_gprs_get_modem
Signed-off-by: Jarko Poutiainen <Jarko.Poutiainen@oss.tieto.com>
2014-10-31 14:54:39 +02:00
Jarko Poutiainen
0d8b576ab6 Merge pull request #261 from jpoutiai/sim-fix
[RILMODEM] query password state and prevent double sim initialisation
2014-10-30 13:59:09 +02:00
Jarko Poutiainen
c16121469b [RILMODEM] query password state and prevent double sim initialisation
Signed-off-by: Jarko Poutiainen <Jarko.Poutiainen@oss.tieto.com>
2014-10-29 10:04:06 +02:00
Jarko Poutiainen
812f552ace Merge pull request #260 from jpoutiai/vc-delay-nro-storing
[voicecall] src/voicecall.c MO call delay storing number
2014-10-28 10:38:24 +02:00
Kuba Pawlak
42ebb69384 he910: Update copyright 2014-10-22 21:23:25 -05:00
Kuba Pawlak
45478b17cf he910: enable location raporting atom 2014-10-22 21:22:33 -05:00
Kuba Pawlak
88f46a9b01 udev: add GPS port definition for HE910 2014-10-22 21:22:24 -05:00
Denis Kenzior
2abcb85809 telitmodem: Fix a few coding style violations 2014-10-22 21:21:49 -05:00
Denis Kenzior
331700a697 AUTHORS: Mention Kuba's contributions 2014-10-22 21:21:18 -05:00
Kuba Pawlak
a753d6c012 telitmodem: location reporting driver 2014-10-22 21:15:35 -05:00
Kuba Pawlak
d39007c948 doc: new file doc/telit-modem.txt 2014-10-22 21:10:50 -05:00
Jarko Poutiainen
fe52d1dc53 [voicecall] src/voicecall.c MO call delay storing number
Signed-off-by: Jarko Poutiainen <Jarko.Poutiainen@oss.tieto.com>
2014-10-22 11:43:14 +03:00
Jarko Poutiainen
8be724836e Merge pull request #259 from jpoutiai/gprs
rilmodem gprs fixes
2014-10-22 10:58:42 +03:00
Jarko Poutiainen
8c96a7e091 Merge pull request #258 from jpoutiai/roaming-fix
Roaming fix
2014-10-22 10:13:01 +03:00
Jarko Poutiainen
f9bd555dc0 [RILMODEM] style fix
Signed-off-by: Jarko Poutiainen <Jarko.Poutiainen@oss.tieto.com>
2014-10-22 09:16:18 +03:00
Denis Kenzior
6c4ac05fbc emulator: Refine +BIND support 2014-10-20 13:40:29 -05:00
Denis Kenzior
934ea9a9fe hfp_ag_bluez5: Bump HFP version to 1.7 2014-10-20 13:40:28 -05:00
Denis Kenzior
cf90f1505d emulator_fuzz: Add test plugin
This plugin creates an org.ofono.test.EmulatorFuzz interface on path
/test.  Currently only one method is implemented, SetIndicatorActive.

SetIndicatorActive("DistractedDrivingReduction", True|False) allows to
activate / deactivate the HF indicator via +BIND unsolicited
notification.
2014-10-20 13:40:28 -05:00
Denis Kenzior
f9d5ee5fa9 emulator: Implement new API 2014-10-20 13:40:28 -05:00
Denis Kenzior
e2785b1865 include: Add API to (de)activate HF indicators 2014-10-20 13:40:28 -05:00
Denis Kenzior
fb1b213e22 test: Add test/set-ddr
Script to set DistractedDrivingReduction property
2014-10-20 13:40:28 -05:00
Denis Kenzior
d3560b3784 handsfree: Be extra pedantic with booleans 2014-10-20 13:40:28 -05:00
Denis Kenzior
017c1161d4 hfp_hf_bluez5: Use latest HFP version 2014-10-20 13:40:28 -05:00
Denis Kenzior
de02f68a2e handsfree: Don't try to send a method return
When we are simply updating the AG of HF indicator changes, do not try
to send a method return message.
2014-10-20 13:40:28 -05:00
Denis Kenzior
0f28d9206d slc: Make sure to initialize variables 2014-10-20 13:40:28 -05:00
Denis Kenzior
eef67018b6 hfp: Implement +BIND notifications 2014-10-20 13:40:28 -05:00
Denis Kenzior
299ffc9620 hfp: Notify core of HF indicators supported by AG
This information was obtained from SLC negotiation
2014-10-20 13:40:28 -05:00
Denis Kenzior
39f08a5e1c hfp: Track supported / active indicators
This information is obtained during SLC establishment
2014-10-20 13:40:28 -05:00
Denis Kenzior
6c0f90fc1b handsfree: Implement new HF indicators API 2014-10-20 13:40:28 -05:00
Denis Kenzior
33537adb9f include: Add HF Indicators related API 2014-10-20 13:40:28 -05:00
Denis Kenzior
e176a9019f hfp: Add implementation of +BIEV 2014-10-20 13:40:28 -05:00
Denis Kenzior
7166aebd51 emulator: Refactor data types 2014-10-20 13:40:28 -05:00
Denis Kenzior
debb0d2d3e hfp: Add HF Indicators BRSF feature for 1.7
If HFP 1.7 client is used, enable the right BRSF feature
2014-10-20 13:40:28 -05:00
Denis Kenzior
ab5b6d1217 handsfree: Skeleton implementation of DDR
Distracted Driving Reduction or Enhanced Safety is implemented using HF
indicator 0x0001
2014-10-20 13:40:28 -05:00
Denis Kenzior
7e3a6628fa handsfree: Add new driver method for HF indicators 2014-10-20 13:40:28 -05:00
Denis Kenzior
fa105c4ba6 hfp: Add initial SLC negotiation for HFP 1.7 2014-10-20 13:40:28 -05:00
Denis Kenzior
99c03292ad doc: Add Distracted Driving Reduction to Handsfree 2014-10-20 13:40:28 -05:00
Denis Kenzior
66cf2a30fa handsfree: Implement new Features property value 2014-10-20 13:40:28 -05:00
Denis Kenzior
a4fa356b16 doc: Add 'hf-indicators' feature to Handsfree API 2014-10-20 13:40:28 -05:00
Denis Kenzior
43e83852dc emulator: Enable HF Indicator feature 2014-10-20 13:40:28 -05:00
Denis Kenzior
36a21da227 emulator: Extend BRSF bitmap
The current check of 8 bits is not enough with HFP 1.7
2014-10-20 13:40:28 -05:00
Denis Kenzior
bef4d610a3 emulator: Add +BIEV implementation 2014-10-20 13:40:28 -05:00
Denis Kenzior
2d158167c2 emulator: Add +BIND implementation 2014-10-20 13:40:27 -05:00
Denis Kenzior
02c5b73f6e emulator: Fix CHLD=? not treated as part of SLC 2014-10-20 13:40:27 -05:00
Denis Kenzior
0727da1d5b emulator: Improve SLC establishment logic 2014-10-20 13:40:27 -05:00
Denis Kenzior
d292e0e0ed hfp: Add enum for known HF Indicators 2014-10-20 13:40:27 -05:00
Denis Kenzior
881207ce18 hfp: Update for new HFP 1.7 values 2014-10-20 13:40:27 -05:00
Denis Kenzior
0f0733c348 doc: Fixup Handsfree API 2014-10-20 13:40:27 -05:00
Jarko Poutiainen
71fd5c148a [RILMODEM] recheck status also in ril_data_probe_reg_cb
Signed-off-by: Jarko Poutiainen <Jarko.Poutiainen@oss.tieto.com>
2014-10-20 10:29:18 +03:00
Jarko Poutiainen
476e440f47 [RILMODEM] recheck status value before using it
Signed-off-by: Jarko Poutiainen <Jarko.Poutiainen@oss.tieto.com>
2014-10-20 10:26:54 +03:00
Jarko Poutiainen
35440277d1 [RILMODEM] prevent datacall slipping through when roaming disabled
Signed-off-by: Jarko Poutiainen <Jarko.Poutiainen@oss.tieto.com>
2014-10-20 09:56:07 +03:00
Jarko Poutiainen
4f67e6743e [RILMODEM]publish get_current_network_status
Signed-off-by: Jarko Poutiainen <Jarko.Poutiainen@oss.tieto.com>
2014-10-20 09:55:40 +03:00
Jarko Poutiainen
c9ba23ae3d [RILMODEM] get network status from core
Signed-off-by: Jarko Poutiainen <Jarko.Poutiainen@oss.tieto.com>
2014-10-20 09:50:15 +03:00
Jarko Poutiainen
dcdddee5c5 [RILMODEM] introduce ril_roaming_allowed
Signed-off-by: Jarko Poutiainen <Jarko.Poutiainen@oss.tieto.com>
2014-10-14 09:31:37 +03:00
Jarko Poutiainen
195c2c6a1e [RILMODEM] prepare ril_roaming_allowed to be published
Signed-off-by: Jarko Poutiainen <Jarko.Poutiainen@oss.tieto.com>
2014-10-14 09:30:53 +03:00
Jarko Poutiainen
51cf33c206 Merge pull request #257 from jpoutiai/master
[RILMODEM] free before calling g_strdup to avoid mem leak
2014-10-10 11:08:50 +03:00
Jarko Poutiainen
08ddddc8d2 [RILMODEM] free before calling g_strdup to avoid mem leak
Signed-off-by: Jarko Poutiainen <Jarko.Poutiainen@oss.tieto.com>
2014-10-10 10:51:02 +03:00
Marcel Holtmann
8ebb17977b handsfree-audio: Fix broken coding style in switch statement 2014-09-20 16:13:45 +02:00
Alban Crequy
7fb4899970 gdbus: Fix match rule for NameOwnerChanged
When subscribing to the D-Bus signal NameOwnerChanged from the bus driver,
specify the object path and the sender in the match rule. Otherwise, random
connections on the bus could impersonate the bus driver.
2014-09-15 18:03:46 +02:00
Luiz Augusto von Dentz
1e0c41889f gdbus: Fix crash when watch is toggled or disconnected
This partially reverts 510b32b7156625b9df737c916b7a7a5c6fb285b9 since it
still necessary to take a reference before calling dbus_watch_handle
since internally it can call watch_info_free as in the following trace:

 Invalid read of size 8
   at 0x121085: watch_func (mainloop.c:105)
   by 0x4C72694: g_main_context_dispatch (gmain.c:2539)
   by 0x4C729C7: g_main_context_iterate.isra.23 (gmain.c:3146)
   by 0x4C72DC1: g_main_loop_run (gmain.c:3340)
   by 0x120541: main (main.c:551)
 Address 0x5bbcd90 is 16 bytes inside a block of size 24 free'd
   at 0x4A079AE: free (vg_replace_malloc.c:427)
   by 0x4C7837E: g_free (gmem.c:252)
   by 0x4F708BF: dbus_watch_set_data (dbus-watch.c:614)
   by 0x4F70938: _dbus_watch_unref (dbus-watch.c:132)
   by 0x4F6E9A7: _dbus_transport_handle_watch (dbus-transport.c:884)
   by 0x4F59AFB: _dbus_connection_handle_watch (dbus-connection.c:1497)
   by 0x4F70AF9: dbus_watch_handle (dbus-watch.c:683)
   by 0x121084: watch_func (mainloop.c:103)
   by 0x4C72694: g_main_context_dispatch (gmain.c:2539)
   by 0x4C729C7: g_main_context_iterate.isra.23 (gmain.c:3146)
   by 0x4C72DC1: g_main_loop_run (gmain.c:3340)
   by 0x120541: main (main.c:551)
2014-09-08 05:48:48 +02:00
Luiz Augusto von Dentz
08e673050a gdbus: Fix crash when calling g_dbus_add_service_watch
If g_dbus_add_service_watch is called for service which bus name is
already known the following crash can happen:

invalid read of size 1
  at 0x4C2A2F2: strlen (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
  by 0x4E97722: g_strdup (in /usr/lib64/libglib-2.0.so.0.3800.2)
  by 0x405B0C: update_name_cache (watch.c:435)
  by 0x405C37: update_service (watch.c:593)
  by 0x4E7A2A5: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.3800.2)
  by 0x4E7A627: ??? (in /usr/lib64/libglib-2.0.so.0.3800.2)
  by 0x4E7AA39: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.3800.2)
  by 0x4038EA: client_ready (test-gdbus-client.c:1014)
  by 0x4E9E5E0: ??? (in /usr/lib64/libglib-2.0.so.0.3800.2)
  by 0x4E9E7A5: ??? (in /usr/lib64/libglib-2.0.so.0.3800.2)
  by 0x4E9EB1A: g_test_run_suite (in /usr/lib64/libglib-2.0.so.0.3800.2)
  by 0x403614: main (test-gdbus-client.c:1058)
Address 0x5dbe5d0 is 0 bytes inside a block of size 7 free'd
  at 0x4C28577: free (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
  by 0x4E7FF7E: g_free (in /usr/lib64/libglib-2.0.so.0.3800.2)
  by 0x405B04: update_name_cache (watch.c:434)
  by 0x405C37: update_service (watch.c:593)
  by 0x4E7A2A5: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.3800.2)
  by 0x4E7A627: ??? (in /usr/lib64/libglib-2.0.so.0.3800.2)
  by 0x4E7AA39: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.3800.2)
  by 0x4038EA: client_ready (test-gdbus-client.c:1014)
  by 0x4E9E5E0: ??? (in /usr/lib64/libglib-2.0.so.0.3800.2)
  by 0x4E9E7A5: ??? (in /usr/lib64/libglib-2.0.so.0.3800.2)
  by 0x4E9EB1A: g_test_run_suite (in /usr/lib64/libglib-2.0.so.0.3800.2)
  by 0x403614: main (test-gdbus-client.c:1058)
2014-09-08 05:48:48 +02:00
Luiz Augusto von Dentz
1b1b1861ab Revert "gdbus: Don't include just added interfaces in GetManagedObjects"
This actually creates a problem since the code now does flush any pending
message on the queue any signal will be send right away before the
actual reply to GetManagedObjects which will not contain those interfaces.
2014-09-08 05:48:48 +02:00
Andrei Emeltchenko
8a4c29ca74 gdbus: Fix use after free
Refactor filter_data_remove_callback so that we do not iterate over
freed pointer.
2014-09-08 05:48:48 +02:00
Claudio Takahasi
9aeea028ed gdbus: Avoid reporting GDBusClient disconnect twice
No matter if disconnection was reported previously, g_dbus_client_unref()
was always calling service disconnect callback. This patch fix the
following scenario:
1) service disconnects from the bus
2) disconnect callback gets called
3) client calls g_dbus_client_unref(), disconnect callback is called
   again.
2014-09-08 05:48:48 +02:00
Denis Kenzior
22e892a22e build: Avoid warnings about _FORTIFY_SOURCE
Gentoo (and others) define _FORTIFY_SOURCE=2 by default.  We redefine
it, resulting in an error / configure failure.
2014-08-01 09:29:40 -05:00
Denis Kenzior
361eed7b9a ublox: Minor style cleanup 2014-07-08 08:58:48 -05:00
Denis Kenzior
864efe1add ublox: Remove unneeded VENDOR flags
devinfo and netreg atoms don't use vendor specific behavior
2014-07-08 08:56:55 -05:00
Philip Paeps
0d8a06af30 plugins: new driver for u-blox SARA-U270 modems
This driver may also work (perhaps with more or less trivial changes)
with other u-blox modems (SARA, LISA, LEON) but this hasn't been tested.
2014-07-08 08:53:13 -05:00
Philip Paeps
293c701e25 atmodem: set the auth method for u-blox modems 2014-07-08 08:52:25 -05:00
Philip Paeps
cca3e085b3 sim: query u-blox PIN retries with AT+UPINCNT 2014-07-08 08:51:54 -05:00
Philip Paeps
7f29608feb udevng: add detection logic for u-blox modems 2014-07-08 08:50:20 -05:00
Denis Kenzior
1f3e30f1ba quectel: Minor style cleanup 2014-07-08 08:44:21 -05:00
Denis Kenzior
7ab4034bf4 quectel: Remove unneeded VENDOR flags
Only the sim atom has QUECTEL specific code
2014-07-08 08:43:01 -05:00
Philip Paeps
bb1984cabb plugins: add a new driver for Quectel UC15 modems 2014-07-08 08:42:05 -05:00
Philip Paeps
6df64cd1a9 gprs: add support for u-blox +UREG URCs 2014-06-30 14:03:08 -05:00
Philip Paeps
4a0831bc80 atmodem: add vendor u-blox 2014-06-30 13:59:46 -05:00
Denis Kenzior
b2bfdd69d2 atmodem: Minor style fixups 2014-06-30 13:44:40 -05:00
Philip Paeps
1588e7c082 sim: query Quectel UC15 PIN retries with AT+QPINC? 2014-06-30 13:35:19 -05:00
Philip Paeps
5cffd8af95 udevng: add detection logic for Quectel modems 2014-06-30 13:26:51 -05:00
Philip Paeps
d2f6ffc18d atmodem: add vendor Quectel 2014-06-30 13:26:25 -05:00
Sergio Checa Blanco
6369cc902c hfpmodem: Fix crash with more than two calls
A periodic CLCC polling is started when there is an ongoing multiparty
call and a new call appears in the system. A simple way to reproduce
the crashing scenario is:

1. Place a call.
2. Place a second call.
3. Create a multiparty call with both calls.
4. Place a third call (incoming or outgoing does not matter).
5. Disconnect HFP from the modem.

Within the function ciev_callheld_notify, the AT+CLCC command is also
invoked, thus a new cyclic CLCC polling is started, and it overwrites
the timer resource identifier stored in voicecall_data.clcc_source.
This means that there are several timers doing the CLCC polling, but
only one of those is under control, i.e. it can be removed through its
source identifier, hence a timer source leak.

This has a fatal consequence when the HFP modem is disconnected. The
function hfp_voicecall_remove stops the timer that is under control
before freeing the voicecall_data struct. However there are other timers
that are still active and will execute its handler poll_clcc afterwards.
Inside poll_clcc the driver_data is accessed, which is already NULL.

A solution for this is to avoid starting a CLCC polling if there is
already one active, i.e. clcc_source is not 0. By doing this the
uncontrolled timers will not cycle forever.
2014-06-30 13:22:10 -05:00
Marcel Holtmann
d05b718cc0 Release 1.15 2014-06-29 22:20:08 +02:00
Philip Paeps
c144fadca6 gprs: provision the authentication method 2014-06-24 12:46:18 -05:00
Philip Paeps
532e8020e5 mbpi: add support for provisioning the auth method
Use the authentication method from the mobile-broadband-provider-info
database if it is specified and supported (we support CHAP and PAP).
Default to CHAP if the database does not specify a method (i.e.: the
previous behaviour).
2014-06-24 12:46:18 -05:00
Philip Paeps
310915429b include: add auth method to the provisioning API 2014-06-24 12:46:18 -05:00
Denis Kenzior
9285ec0d89 AUTHORS: Mention Philip's contributions 2014-06-21 12:05:43 -05:00
Philip Paeps
8cbe061c3b atmodem: set the PPP authentication method to use 2014-06-21 12:02:51 -05:00
Denis Kenzior
3e13676766 gprs: Make the code a bit easier to read 2014-06-21 12:02:05 -05:00
Philip Paeps
73831c3d76 gprs: make PPP authentication method configurable
Add a new "AuthenticationMethod" property to select between "pap"
and "chap" PPP authentication, defaulting to "chap" (i.e.: previous
behaviour).
2014-06-21 11:58:03 -05:00
Philip Paeps
7011dcdf2f include: add auth method to the gprs context API 2014-06-21 11:55:30 -05:00
Philip Paeps
f6341502c8 doc: describe the AuthenticationMethod property 2014-06-21 11:55:03 -05:00
Denis Kenzior
8edaaaf210 gatchat: Fix up minor coding style issues 2014-06-21 11:54:26 -05:00
Philip Paeps
a88662d23c gatchat: implement PAP authentication
Make the authentication method configurable, CHAP or PAP, defaulting to
CHAP (i.e.: previous behaviour).

Implementation details:

 o If PAP is configured, we NAK the CHAP authentication protocol option
   in LCP configuration requests and suggest PAP instead.  This works
   around the amusing requirement of 3GPP TS 29.061 that modems must
   send a forced positive acknowledgement of the authentication method
   tried (i.e.: the modem will successfully accept any CHAP handshake,
   but if the network only supports PAP, the modem will hang up
   when it tries and fails to activate the PDP context)

 o The PAP Authenticate-Request is resent a hard-coded three times at
   ten-second intervals.  This may be a bit too persistent.  Chances
   are if it doesn't work the first time, it'll never work, but the
   RFC insists that we MUST retry.
2014-06-21 11:50:34 -05:00
Denis Kenzior
1dd8580930 AUTHORS: Mention Sergio's contributions 2014-06-21 11:46:28 -05:00
Sergio Checa Blanco
65be2b344c hfpmodem: Split AT+VTS command into multiple +VTS
According to the standard "3GPP 27.007 v6.8.0" Appendix C.2.11,
when sending multiple DTMF characters, these must go in individual
+VTS commands for each tone. This adopts the AT modem approach.

Before: AT+VTS=1234\r
After:  AT+VTS=1;+VTS=2;+VTS=3;+VTS=4\r
2014-06-21 11:45:44 -05:00
Alfonso Sanchez-Beato
62c34467a2 test: Adapt data test scripts to multi-modem
Some tests scripts were not ready to handle situations with more than
one modem present. This change fixes the data context scripts.
2014-06-10 23:36:09 -05:00
Alfonso Sanchez-Beato
d9f252fb61 test: Adapt voice call test scripts to multi-modem
Some tests scripts were not ready to handle situations with more than
one modem present. This change fixes the scripts that handle voice
calls.
2014-06-10 23:23:51 -05:00
Denis Kenzior
815d62888f hfp: Fix case where RING never arrives 2014-05-30 12:25:23 -05:00
Denis Kenzior
35feae07e5 hfp: Use proper prefix
Otherwise the BCS command can consume unsolicited notifications.

ofonod[3270]: < \r\n+BCS: 2\r\n
ofonod[3270]: > AT+BCS=2\r
ofonod[3270]: < \r\n+CIEV: 1,1\r\n
ofonod[3270]: < \r\n+CIEV: 2,0\r\n
ofonod[3270]: < \r\nOK\r\n
2014-05-21 12:08:37 -05:00
346 changed files with 59624 additions and 12229 deletions

30
ofono/.gitignore vendored
View File

@@ -42,6 +42,36 @@ unit/test-mux
unit/test-caif
unit/test-stkutil
unit/test-cdmasms
unit/test-ril_util
unit/test-rilmodem-cb
unit/test-rilmodem-cs
unit/test-rilmodem-gprs
unit/test-rilmodem-sms
unit/test-sailfish_cell_info
unit/test-sailfish_cell_info_dbus
unit/test-sailfish_manager
unit/test-sailfish_sim_info
unit/test-sms-filter
unit/test-*.log
unit/test-*.trs
unit/test-grilreply
unit/test-grilrequest
unit/test-grilunsol
unit/test-provision
unit/html
plugins/sailfish_manager/*.gcda
plugins/sailfish_manager/*.gcno
drivers/*/*.gcda
drivers/*/*.gcno
drivers/*/*.gcov
plugins/*/*.gcda
plugins/*/*.gcno
plugins/*/*.gcov
*/*.gcda
*/*.gcno
*/*.gcov
tools/huawei-audio
tools/auto-enable

View File

@@ -96,3 +96,30 @@ Tony Espy <espy@canonical.com>
Martin Pitt <martin.pitt@ubuntu.com>
Alfonso Sanchez-Beato <alfonso.sanchez-beato@canonical.com>
Jussi Pakkanen <jussi.pakkanen@canonical.com>
Sergio Checa Blanco <sergio.checa@bmw-carit.de>
Philip Paeps <philip@paeps.cx>
Kuba Pawlak <kubax.t.pawlak@intel.com>
Tommi Kenakkala <tommi.kenakkala@tieto.com>
Alex J Lennon <ajlennon@dynamicdevices.co.uk>
Sergey Alirzaev <zl29ah@gmail.com>
Marko Sulejic <marko.sulejic@hale.at>
Johannes 'josch' Schauer <josch@mister-muffin.de>
Simon Fels <simon.fels@canonical.com>
John Ernberg <john.ernberg@actia.se>
Dongsu Park <dongsu@endocode.com>
Dragos Tatulea <dragos@endocode.com>
Samrat Guha Niyogi <samrat.guha.niyogi@intel.com>
Anirudh Gargi <anirudh.gargi@intel.com>
Nishanth V <nishanth.v@intel.com>
Antara Borwankar <antara.borwankar@gmail.com>
Martin Chaplet <m.chaplet@kerlink.fr>
Suman Mallela <suman.m@intel.com>
Rajagopal Aravindan <rajagopalx.aravindan@intel.com>
Antoine Aubert <a.aubert@overkiz.com>
Djalal Harouni <djalal@endocode.com>
Christophe Ronco <c.ronco@kerlink.fr>
Vincent Cesson <vincent.cesson@smile.fr>
Piotr Haber <gluedig@gmail.com>
André Draszik <git@andred.net>
Lukasz Nowak <lnowak@tycoint.com>
Jonas Bonn <jonas@southpole.se>

View File

@@ -1,3 +1,84 @@
ver 1.20:
Fix issue with context removal before activation.
Fix issue with update during GPRS context activation.
Fix issue with receiving UTF-16 encoded messages.
Fix issue with invalid access in CBS decoding.
Fix issue with signal strength on QMI modems.
Fix issue with PIN handling with QMI modems.
Fix issue with QMI notification message handling.
Fix issue with facility lock query on SIM removal.
Fix issue with parsing +CLCC and +CCWA fields.
Add support for obtaining IMSI via EF reading.
Add support for additional netmon info types.
Add support for provisioning via configuration files.
Add support for Gemalto P-family series of modems.
Add support for Telit HE910 and UE910 variants.
Add support for Intel SoFIA SIM Toolkit interfaces.
Add support for Intel SoFIA LTE features.
Add support for U-Blox TOBY-L2 LTE feature.
Add support for dedicated LTE atom.
ver 1.19:
Fix issue with DHCP parsing and Huawei modems.
Fix issue with detecting Huawei E3372 modem.
Fix issue with handling serving cell info.
Fix issue with handling SIM SC facility lock.
Fix issue with Android RIL PIN retry logic.
Fix issue with Android RIL and RAT handling.
Add support for Android RIL cell broadcast.
Add support for SoFIA 3GR thermal management.
ver 1.18:
Fix issue with cell broadcast and use-after-fee.
Fix issue with repeated held call indicator.
Fix issue with +CCWA and connection setup.
Fix issue with empty operator scan results.
Fix issue with persistent RAT mode handling.
Fix issue with multiparty call introspection.
Fix issue with GRPS context introspection.
Fix issue with stale context deactivation.
Add support for automatic context activation.
Add support for SIM service provider names.
Add support for handling allowed APN lists.
Add support for network monitoring interface.
Add support for U-Blox TOBY-L2 modem series.
Add support for Sierra MC73xx QMI modems.
Add support for SoFIA 3GR modem series.
Add support for upower battery monitoring.
Add support for gateway audio card types.
Add support for Handsfree audio driver.
Add support for Android RIL integration.
ver 1.17:
Fix issue with alphanumeric TP-OA handling.
Fix issue with push notification origin port.
Fix issue with reading of EF_MWIS records.
Fix issue with handling AT+CPINR results.
Fix issue with SIM state polling for Sierra modems.
Fix issue with HFP handling and AT command prefixes.
Fix issue with HFP and extra CCWA event handling.
Fix issue with HFP call state and +CHUP errors.
ver 1.16:
Fix issue with PIN retry handling.
Fix issue with HFP and multiple calls.
Add support for Distracted Driving Reduction.
Add support for available technologies property.
Add support for Telit location reporting driver.
Add support for u-blox SARA-U270 modems.
Add support for Quectel UC15 modems.
ver 1.15:
Fix issue with EF_PNN access affecting PLMN display.
Fix issue with SIM detection and Telit HE910 modems.
Fix issue with Mobile Provider Database provisioning.
Fix issue with bit-shifting and ID mapping allocations.
Fix issue with Handsfree and unsolicited notifications.
Fix issue with Handsfree and three way calling feature.
Add support for Handsfree subscriber number feature.
Add support for Handsfree multiple DTMF characters.
Add support for PAP authentication.
ver 1.14:
Add support for Apple Siri specific Handsfree commands.
Add support for provisioning of MMSC and Message Proxy.

View File

@@ -113,3 +113,5 @@ doc/coding-style.txt.
a feature that touches files under 'include/', 'src/' and 'drivers/'
directories, split in three separated patches, taking care not to
break compilation.
4) Submit patches using git send-email to ofono@ofono.org

View File

@@ -21,11 +21,20 @@ pkginclude_HEADERS = include/log.h include/plugin.h include/history.h \
include/cdma-connman.h include/gnss.h \
include/private-network.h include/cdma-netreg.h \
include/cdma-provision.h include/handsfree.h \
include/handsfree-audio.h include/sim-mnclength.h \
include/oemraw.h include/siri.h
include/sim-mnclength.h \
include/handsfree-audio.h include/siri.h \
include/sms-filter.h \
include/netmon.h include/lte.h \
include/storage.h \
gdbus/gdbus.h
nodist_pkginclude_HEADERS = include/version.h
if SAILFISH_MANAGER
nodist_pkginclude_HEADERS += include/sailfish_cell_info.h \
include/sailfish_manager.h include/sailfish_watch.h
endif
local_headers = $(foreach file,$(pkginclude_HEADERS) \
$(nodist_pkginclude_HEADERS), \
include/ofono/$(notdir $(file)))
@@ -96,20 +105,16 @@ gisi_sources = gisi/client.c gisi/client.h gisi/common.h \
gisi/server.c gisi/server.h \
gisi/socket.c gisi/socket.h
gril_sources = gril/gril.h gril/gril.c gril/grilio.h \
gril/grilio.c gril/grilutil.h \
gril/grilutil.c gril/ringbuffer.h \
gril/gfunc.h gril/ril.h \
gril_sources = gril/gril.h gril/gril.c \
gril/grilio.h gril/grilio.c \
gril/grilutil.h gril/grilutil.c \
gril/gfunc.h gril/gril.h \
gril/parcel.c gril/parcel.h \
gril/grilreply.c gril/grilreply.h \
gril/grilrequest.c gril/grilrequest.h \
gril/grilunsol.c gril/grilunsol.h
gril/ril_constants.h
btio_sources = btio/btio.h btio/btio.c
if UDEV
builtin_modules += udev
builtin_sources += plugins/udev.c
builtin_cflags += @UDEV_CFLAGS@
builtin_libadd += @UDEV_LIBS@
@@ -117,18 +122,84 @@ builtin_modules += udevng
builtin_sources += plugins/udevng.c
endif
if SAILFISH_MANAGER
builtin_modules += sailfish_manager
builtin_sources += plugins/sailfish_manager/sailfish_cell_info.c \
plugins/sailfish_manager/sailfish_cell_info_dbus.c \
plugins/sailfish_manager/sailfish_manager.c \
plugins/sailfish_manager/sailfish_manager_dbus.c \
plugins/sailfish_manager/sailfish_sim_info.c \
plugins/sailfish_manager/sailfish_sim_info_dbus.c \
plugins/sailfish_manager/sailfish_watch.c
endif
if RILMODEM
builtin_sources += $(gril_sources)
if SAILFISH_RILMODEM
builtin_modules += ril
builtin_sources += plugins/ril.c
builtin_sources += drivers/ril/ril_call_barring.c \
drivers/ril/ril_call_forward.c \
drivers/ril/ril_call_settings.c \
drivers/ril/ril_call_volume.c \
drivers/ril/ril_cell_info.c \
drivers/ril/ril_config.c \
drivers/ril/ril_cbs.c \
drivers/ril/ril_data.c \
drivers/ril/ril_devinfo.c \
drivers/ril/ril_ecclist.c \
drivers/ril/ril_gprs.c \
drivers/ril/ril_gprs_context.c \
drivers/ril/ril_modem.c \
drivers/ril/ril_netmon.c \
drivers/ril/ril_netreg.c \
drivers/ril/ril_network.c \
drivers/ril/ril_oem_raw.c \
drivers/ril/ril_phonebook.c \
drivers/ril/ril_plugin.c \
drivers/ril/ril_radio.c \
drivers/ril/ril_radio_caps.c \
drivers/ril/ril_radio_settings.c \
drivers/ril/ril_sim.c \
drivers/ril/ril_sim_card.c \
drivers/ril/ril_sim_settings.c \
drivers/ril/ril_sms.c \
drivers/ril/ril_stk.c \
drivers/ril/ril_ussd.c \
drivers/ril/ril_util.c \
drivers/ril/ril_vendor.c \
drivers/ril/ril_voicecall.c
# Vendor specific extensions
builtin_sources += drivers/ril/ril_vendor_mtk.c
if DATAFILES
dist_conf_DATA += drivers/ril/ril_subscription.conf
endif
else
builtin_sources += $(gril_sources)
builtin_modules += rildev
builtin_sources += plugins/rildev.c
builtin_modules += ril
builtin_sources += plugins/ril.c plugins/ril.h
builtin_modules += infineon
builtin_sources += plugins/infineon.c
builtin_modules += ril_intel
builtin_sources += plugins/ril_intel.c
builtin_modules += rilmodem
builtin_sources += drivers/rilmodem/rilmodem.h \
drivers/rilmodem/vendor.h \
drivers/rilmodem/rilmodem.c \
drivers/rilmodem/devinfo.c \
drivers/rilmodem/network-registration.c \
drivers/rilmodem/voicecall.c \
drivers/rilmodem/voicecall.h \
drivers/rilmodem/call-volume.c \
drivers/rilmodem/gprs.c \
drivers/rilmodem/gprs-context.c \
@@ -136,16 +207,17 @@ builtin_sources += drivers/rilmodem/rilmodem.h \
drivers/rilmodem/sms.c \
drivers/rilmodem/rilutil.c \
drivers/rilmodem/rilutil.h \
drivers/rilmodem/radio-settings.c \
drivers/rilmodem/phonebook.c \
drivers/rilmodem/ussd.c \
drivers/rilmodem/call-settings.c \
drivers/rilmodem/call-forwarding.c \
drivers/rilmodem/cbs.c \
drivers/rilmodem/oemraw-messages.c \
drivers/rilmodem/radio-settings.c \
drivers/rilmodem/call-barring.c \
drivers/rilmodem/stk.c
drivers/rilmodem/netmon.c \
drivers/rilmodem/stk.c \
drivers/rilmodem/cbs.c \
drivers/infineonmodem/infineon_constants.h \
drivers/rilmodem/lte.c
endif
endif
if ISIMODEM
@@ -203,11 +275,13 @@ qmi_sources = drivers/qmimodem/qmi.h drivers/qmimodem/qmi.c \
drivers/qmimodem/ctl.h \
drivers/qmimodem/dms.h \
drivers/qmimodem/nas.h \
drivers/qmimodem/nas.c \
drivers/qmimodem/uim.h \
drivers/qmimodem/wms.h \
drivers/qmimodem/wds.h \
drivers/qmimodem/pds.h \
drivers/qmimodem/common.h
drivers/qmimodem/common.h \
drivers/qmimodem/wda.h
builtin_modules += qmimodem
builtin_sources += $(qmi_sources) \
@@ -232,8 +306,7 @@ endif
if ATMODEM
builtin_modules += atmodem
builtin_sources += $(gatchat_sources) \
drivers/atmodem/atmodem.h \
builtin_sources += drivers/atmodem/atmodem.h \
drivers/atmodem/atmodem.c \
drivers/atmodem/call-settings.c \
drivers/atmodem/sms.c \
@@ -309,6 +382,13 @@ builtin_sources += drivers/atmodem/atutil.h \
drivers/mbmmodem/stk.c \
drivers/mbmmodem/location-reporting.c
builtin_modules += telitmodem
builtin_sources += drivers/atmodem/atutil.h \
drivers/telitmodem/telitmodem.h \
drivers/telitmodem/telitmodem.c \
drivers/telitmodem/location-reporting.c \
drivers/telitmodem/gprs-context-ncm.c
builtin_modules += hsomodem
builtin_sources += drivers/atmodem/atutil.h \
drivers/hsomodem/hsomodem.h \
@@ -365,15 +445,28 @@ builtin_sources += drivers/atmodem/atutil.h \
drivers/speedupmodem/speedupmodem.c \
drivers/speedupmodem/ussd.c
builtin_modules += ubloxmodem
builtin_sources += drivers/atmodem/atutil.h \
drivers/ubloxmodem/ubloxmodem.h \
drivers/ubloxmodem/ubloxmodem.c \
drivers/ubloxmodem/gprs-context.c \
drivers/ubloxmodem/netmon.c \
drivers/ubloxmodem/lte.c
builtin_modules += gemaltomodem
builtin_sources += drivers/atmodem/atutil.h \
drivers/gemaltomodem/gemaltomodem.h \
drivers/gemaltomodem/gemaltomodem.c \
drivers/gemaltomodem/location-reporting.c
if PHONESIM
builtin_modules += phonesim
builtin_sources += plugins/phonesim.c
if DATAFILES
dist_conf_DATA += plugins/phonesim.conf
if RILMODEM
dist_conf_DATA += gril/ril_subscription.conf
endif
endif
endif
@@ -429,8 +522,11 @@ builtin_sources += plugins/stemgr.c
builtin_modules += caif
builtin_sources += plugins/caif.c
builtin_modules += tc65
builtin_sources += plugins/tc65.c
builtin_modules += cinterion
builtin_sources += plugins/cinterion.c
builtin_modules += gemalto
builtin_sources += plugins/gemalto.c
builtin_modules += nokia
builtin_sources += plugins/nokia.c
@@ -458,33 +554,56 @@ builtin_sources += plugins/samsung.c
builtin_modules += sim900
builtin_sources += plugins/sim900.c
builtin_modules += connman
builtin_sources += plugins/connman.c
builtin_modules += telit
builtin_sources += plugins/telit.c
builtin_modules += quectel
builtin_sources += plugins/quectel.c
builtin_modules += ublox
builtin_sources += plugins/ublox.c
builtin_modules += he910
builtin_sources += plugins/he910.c
endif
builtin_modules += connman
builtin_sources += plugins/connman.c
builtin_modules += he910
builtin_sources += plugins/he910.c
builtin_modules += mnclength
builtin_sources += plugins/mnclength.c
if BLUETOOTH
if BLUEZ4
builtin_modules += bluez4
builtin_sources += plugins/bluez4.c plugins/bluez4.h
builtin_modules += telit
builtin_sources += plugins/telit.c plugins/bluez4.h
builtin_modules += sap
builtin_sources += plugins/sap.c plugins/bluez4.h
builtin_modules += hfp_bluez4
builtin_sources += plugins/hfp_hf_bluez4.c plugins/bluez4.h
builtin_modules += hfp_ag_bluez4
builtin_sources += plugins/hfp_ag_bluez4.c plugins/bluez4.h
builtin_modules += dun_gw_bluez4
builtin_sources += plugins/dun_gw_bluez4.c plugins/bluez4.h
else
builtin_modules += hfp_bluez5
builtin_sources += plugins/hfp_hf_bluez5.c plugins/bluez5.h
builtin_modules += dun_gw_bluez5
builtin_sources += plugins/dun_gw_bluez5.c plugins/bluez5.h
endif
endif
endif
if BLUETOOTH
if BLUEZ4
builtin_modules += bluez4
builtin_sources += plugins/bluez4.c plugins/bluez4.h
builtin_modules += hfp_ag_bluez4
builtin_sources += plugins/hfp_ag_bluez4.c plugins/bluez4.h
builtin_sources += $(btio_sources)
builtin_cflags += @BLUEZ_CFLAGS@
@@ -493,16 +612,19 @@ else
builtin_modules += bluez5
builtin_sources += plugins/bluez5.c plugins/bluez5.h
builtin_modules += hfp_bluez5
builtin_sources += plugins/hfp_hf_bluez5.c plugins/bluez5.h
builtin_modules += hfp_ag_bluez5
builtin_sources += plugins/hfp_ag_bluez5.c plugins/bluez5.h
builtin_modules += dun_gw_bluez5
builtin_sources += plugins/dun_gw_bluez5.c plugins/bluez5.h
if SAILFISH_BT
builtin_modules += sfos_bt
builtin_sources += plugins/sailfish_bt.c
endif
endif
if UPOWER
builtin_modules += upower
builtin_sources += plugins/upower.c
endif
endif
if NETTIME
@@ -510,17 +632,32 @@ builtin_modules += nettime
builtin_sources += plugins/nettime.c
endif
if SAILFISH_DEBUGLOG
builtin_modules += debuglog
builtin_sources += plugins/sailfish_debuglog.c
endif
if SAILFISH_PROVISION
builtin_sources += plugins/sailfish_provision.c
PROVISION = 1
else
if PROVISION
builtin_sources += plugins/provision.c
endif
endif
if PROVISION
builtin_sources += plugins/mbpi.h plugins/mbpi.c
builtin_modules += provision
builtin_sources += plugins/provision.h plugins/provision.c
builtin_sources += plugins/provision.h
builtin_modules += cdma_provision
builtin_sources += plugins/cdma-provision.c
builtin_modules += mnclength
builtin_sources += plugins/mnclength.c
builtin_modules += file_provision
builtin_sources += plugins/file-provision.c
endif
if MAINTAINER_MODE
@@ -541,6 +678,9 @@ builtin_sources += examples/private-network.c
builtin_modules += stktest
builtin_sources += plugins/stktest.c
builtin_modules += emulator_fuzz
builtin_sources += plugins/emulator_fuzz.c
endif
builtin_modules += smart_messaging
@@ -549,19 +689,21 @@ builtin_sources += plugins/smart-messaging.c
builtin_modules += push_notification
builtin_sources += plugins/push-notification.c
if PUSHFORWARDER
builtin_modules += push_forwarder
builtin_sources += plugins/push-forwarder.c
builtin_cflags += @WSPCODEC_CFLAGS@
builtin_libadd += @WSPCODEC_LIBS@
if SAILFISH_PUSHFORWARDER
builtin_modules += pushforwarder
builtin_sources += plugins/sailfish_pushforwarder.c
endif
builtin_modules += sms_history
builtin_sources += plugins/smshistory.c
builtin_modules += allowed_apns
builtin_sources += plugins/allowed-apns.c
sbin_PROGRAMS = src/ofonod
src_ofonod_SOURCES = $(builtin_sources) src/ofono.ver \
src_ofonod_SOURCES = $(builtin_sources) $(gatchat_sources) src/ofono.ver \
src/mtu-watch.c \
src/main.c src/ofono.h src/log.c src/plugin.c \
src/modem.c src/common.h src/common.c \
src/manager.c src/dbus.c src/util.h src/util.c \
@@ -586,8 +728,10 @@ src_ofonod_SOURCES = $(builtin_sources) src/ofono.ver \
src/cdma-sms.c src/private-network.c src/cdma-netreg.c \
src/cdma-provision.c src/handsfree.c \
src/handsfree-audio.c src/bluetooth.h \
src/hfp.h src/sim-mnclength.c src/oemraw.c \
src/siri.c src/voicecallagent.c
src/sim-mnclength.c src/voicecallagent.c \
src/sms-filter.c src/dbus-queue.c \
src/hfp.h src/siri.c \
src/netmon.c src/lte.c
src_ofonod_LDADD = gdbus/libgdbus-internal.la $(builtin_libadd) \
@GLIB_LIBS@ @DBUS_LIBS@ -ldl
@@ -630,9 +774,13 @@ doc_files = doc/overview.txt doc/ofono-paper.txt doc/release-faq.txt \
doc/sim-api.txt doc/stk-api.txt \
doc/audio-settings-api.txt doc/text-telephony-api.txt \
doc/calypso-modem.txt doc/message-api.txt \
doc/location-reporting-api.txt doc/smshistory-api.txt \
doc/oemraw-api.txt \
doc/certification.txt doc/siri-api.txt
doc/location-reporting-api.txt \
doc/smshistory-api.txt doc/oemraw-api.txt \
doc/certification.txt doc/siri-api.txt \
doc/telit-modem.txt \
doc/networkmonitor-api.txt \
doc/allowed-apns-api.txt \
doc/lte-api.txt
test_scripts = test/backtrace \
@@ -666,6 +814,7 @@ test_scripts = test/backtrace \
test/receive-sms \
test/remove-contexts \
test/send-sms \
test/cancel-sms \
test/set-mic-volume \
test/set-speaker-volume \
test/test-stk-menu \
@@ -729,7 +878,17 @@ test_scripts = test/backtrace \
test/display-icon \
test/set-msisdn \
test/test-voicecallagent \
test/get-network-time
test/get-network-time \
test/set-ddr \
test/register-auto \
test/register-operator \
test/set-sms-smsc \
test/set-sms-bearer \
test/get-serving-cell-info \
test/list-allowed-access-points \
test/enable-throttling \
test/disable-throttling \
test/set-lte-property
if TEST
testdir = $(pkglibdir)/test
@@ -741,35 +900,105 @@ EXTRA_DIST = src/genbuiltin plugins/ofono.rules plugins/ofono-speedup.rules \
dist_man_MANS = doc/ofonod.8
if TEST_COVERAGE
COVERAGE_OPT = --coverage
endif
unit_objects =
unit_tests = unit/test-common unit/test-util unit/test-idmap \
unit/test-simutil unit/test-stkutil \
unit/test-sms unit/test-cdmasms \
unit/test-grilrequest \
unit/test-grilreply \
unit/test-grilunsol \
unit/test-sms unit/test-cdmasms \
unit/test-provision
unit/test-provision unit/test-sms-filter
if SAILFISH_MANAGER
unit_test_sailfish_cell_info_SOURCES = unit/test-sailfish_cell_info.c \
plugins/sailfish_manager/sailfish_cell_info.c
unit_test_sailfish_cell_info_CFLAGS = $(AM_CFLAGS) $(COVERAGE_OPT) \
-Iplugins/sailfish_manager
unit_test_sailfish_cell_info_LDADD = @GLIB_LIBS@ -ldl
unit_objects += $(unit_test_sailfish_cell_info_OBJECTS)
unit_tests += unit/test-sailfish_cell_info
unit_test_sailfish_cell_info_dbus_SOURCES = unit/test-dbus.c \
unit/test-sailfish_cell_info_dbus.c \
unit/fake_sailfish_cell_info.c \
plugins/sailfish_manager/sailfish_cell_info.c \
plugins/sailfish_manager/sailfish_cell_info_dbus.c \
gdbus/object.c \
src/dbus.c src/log.c
unit_test_sailfish_cell_info_dbus_CFLAGS = $(AM_CFLAGS) $(COVERAGE_OPT) \
@DBUS_GLIB_CFLAGS@ -Iplugins/sailfish_manager
unit_test_sailfish_cell_info_dbus_LDADD = @DBUS_GLIB_LIBS@ @GLIB_LIBS@ -ldl
unit_objects += $(unit_test_sailfish_cell_info_dbus_OBJECTS)
unit_tests += unit/test-sailfish_cell_info_dbus
unit_test_sailfish_sim_info_SOURCES = unit/test-sailfish_sim_info.c \
unit/fake_sailfish_watch.c \
plugins/sailfish_manager/sailfish_sim_info.c \
src/storage.c src/watch.c src/log.c
unit_test_sailfish_sim_info_CFLAGS = $(COVERAGE_OPT) $(AM_CFLAGS) \
-DSTORAGEDIR='"/tmp/ofono"' -Iplugins/sailfish_manager
unit_test_sailfish_sim_info_LDADD = @GLIB_LIBS@ -ldl
unit_objects += $(unit_test_sailfish_sim_info_OBJECTS)
unit_tests += unit/test-sailfish_sim_info
unit_test_sailfish_manager_SOURCES = unit/test-sailfish_manager.c \
unit/fake_sailfish_watch.c \
plugins/sailfish_manager/sailfish_manager.c \
plugins/sailfish_manager/sailfish_cell_info.c \
plugins/sailfish_manager/sailfish_sim_info.c \
src/storage.c src/log.c
unit_test_sailfish_manager_CFLAGS = $(AM_CFLAGS) $(COVERAGE_OPT) \
-DSTORAGEDIR='"/tmp/ofono"' -Iplugins/sailfish_manager
unit_test_sailfish_manager_LDADD = @GLIB_LIBS@ -ldl
unit_objects += $(unit_test_sailfish_manager_OBJECTS)
unit_tests += unit/test-sailfish_manager
endif
if RILMODEM
if SAILFISH_RILMODEM
unit_test_ril_util_SOURCES = unit/test-ril_util.c drivers/ril/ril_util.c \
src/log.c
unit_test_ril_util_CFLAGS = $(COVERAGE_OPT) $(AM_CFLAGS)
unit_test_ril_util_LDADD = @GLIB_LIBS@ -ldl
unit_objects += $(unit_test_ril_util_OBJECTS)
unit_tests += unit/test-ril_util
else
unit_tests += unit/test-rilmodem-cs \
unit/test-rilmodem-cs \
unit/test-rilmodem-sms \
unit/test-rilmodem-cb \
unit/test-rilmodem-gprs
endif
endif
noinst_PROGRAMS = $(unit_tests) \
unit/test-sms-root unit/test-mux unit/test-caif
unit_test_common_SOURCES = unit/test-common.c src/common.c src/util.c
unit_test_common_CFLAGS = $(COVERAGE_OPT) $(AM_CFLAGS)
unit_test_common_LDADD = @GLIB_LIBS@
unit_objects += $(unit_test_common_OBJECTS)
unit_test_util_SOURCES = unit/test-util.c src/util.c
unit_test_util_CFLAGS = $(COVERAGE_OPT) $(AM_CFLAGS)
unit_test_util_LDADD = @GLIB_LIBS@
unit_objects += $(unit_test_utils_OBJECTS)
unit_test_idmap_SOURCES = unit/test-idmap.c src/idmap.c
unit_test_idmap_CFLAGS = $(COVERAGE_OPT) $(AM_CFLAGS)
unit_test_idmap_LDADD = @GLIB_LIBS@
unit_objects += $(unit_test_idmap_OBJECTS)
unit_test_simutil_SOURCES = unit/test-simutil.c src/util.c \
src/simutil.c src/smsutil.c src/storage.c
unit_test_simutil_CFLAGS = $(COVERAGE_OPT) $(AM_CFLAGS)
unit_test_simutil_LDADD = @GLIB_LIBS@
unit_objects += $(unit_test_simutil_OBJECTS)
@@ -777,19 +1006,23 @@ unit_test_stkutil_SOURCES = unit/test-stkutil.c unit/stk-test-data.h \
src/util.c \
src/storage.c src/smsutil.c \
src/simutil.c src/stkutil.c
unit_test_stkutil_CFLAGS = $(COVERAGE_OPT) $(AM_CFLAGS)
unit_test_stkutil_LDADD = @GLIB_LIBS@
unit_objects += $(unit_test_stkutil_OBJECTS)
unit_test_sms_SOURCES = unit/test-sms.c src/util.c src/smsutil.c src/storage.c
unit_test_sms_CFLAGS = $(COVERAGE_OPT) $(AM_CFLAGS)
unit_test_sms_LDADD = @GLIB_LIBS@
unit_objects += $(unit_test_sms_OBJECTS)
unit_test_cdmasms_SOURCES = unit/test-cdmasms.c src/cdma-smsutil.c
unit_test_cdmasms_CFLAGS = $(COVERAGE_OPT) $(AM_CFLAGS)
unit_test_cdmasms_LDADD = @GLIB_LIBS@
unit_objects += $(unit_test_cdmasms_OBJECTS)
unit_test_sms_root_SOURCES = unit/test-sms-root.c \
src/util.c src/smsutil.c src/storage.c
unit_test_sms_root_CFLAGS = -DSTORAGEDIR='"/tmp/ofono"' $(COVERAGE_OPT) $(AM_CFLAGS)
unit_test_sms_root_LDADD = @GLIB_LIBS@
unit_objects += $(unit_test_sms_root_OBJECTS)
@@ -800,31 +1033,61 @@ unit_objects += $(unit_test_mux_OBJECTS)
unit_test_caif_SOURCES = unit/test-caif.c $(gatchat_sources) \
drivers/stemodem/caif_socket.h \
drivers/stemodem/if_caif.h
unit_test_caif_CFLAGS = $(COVERAGE_OPT) $(AM_CFLAGS)
unit_test_caif_LDADD = @GLIB_LIBS@
unit_objects += $(unit_test_caif_OBJECTS)
unit_test_grilrequest_SOURCES = unit/test-grilrequest.c $(gril_sources) \
src/log.c gatchat/ringbuffer.c
unit_test_grilrequest_LDADD = @GLIB_LIBS@ -ldl
unit_objects += $(unit_test_grilrequest_OBJECTS)
unit_test_grilreply_SOURCES = unit/test-grilreply.c $(gril_sources) \
src/log.c gatchat/ringbuffer.c
unit_test_grilreply_LDADD = @GLIB_LIBS@ -ldl
unit_objects += $(unit_test_grilreply_OBJECTS)
unit_test_grilunsol_SOURCES = unit/test-grilunsol.c $(gril_sources) \
src/log.c gatchat/ringbuffer.c
unit_test_grilunsol_LDADD = @GLIB_LIBS@ -ldl
unit_objects += $(unit_test_grilunsol_OBJECTS)
unit_test_provision_SOURCES = unit/test-provision.c \
plugins/provision.h plugins/provision.c \
plugins/mbpi.c src/gprs-provision.c \
src/log.c
plugins/provision.h plugins/mbpi.c \
plugins/sailfish_provision.c \
src/gprs-provision.c src/log.c
unit_test_provision_CFLAGS = $(COVERAGE_OPT) $(AM_CFLAGS)
unit_test_provision_LDADD = @GLIB_LIBS@ -ldl
unit_objects += $(unit_test_provision_OBJECTS)
unit_test_sms_filter_SOURCES = unit/test-sms-filter.c \
src/sms-filter.c src/log.c
unit_test_sms_filter_CFLAGS = $(COVERAGE_OPT) $(AM_CFLAGS)
unit_test_sms_filter_LDADD = @GLIB_LIBS@ -ldl
unit_objects += $(unit_test_sms_filter_OBJECTS)
test_rilmodem_sources = $(gril_sources) src/log.c src/common.c src/util.c \
gatchat/ringbuffer.h gatchat/ringbuffer.c \
unit/rilmodem-test-server.h \
unit/rilmodem-test-server.c \
unit/rilmodem-test-engine.h \
unit/rilmodem-test-engine.c \
src/simutil.c \
drivers/rilmodem/rilutil.c
unit_test_rilmodem_cs_SOURCES = $(test_rilmodem_sources) \
unit/test-rilmodem-cs.c \
drivers/rilmodem/call-settings.c
unit_test_rilmodem_cs_LDADD = gdbus/libgdbus-internal.la $(builtin_libadd) \
@GLIB_LIBS@ @DBUS_LIBS@ -ldl
unit_objects += $(unit_test_rilmodem_cs_OBJECTS)
unit_test_rilmodem_sms_SOURCES = $(test_rilmodem_sources) \
unit/test-rilmodem-sms.c \
drivers/rilmodem/sms.c
unit_test_rilmodem_sms_LDADD = gdbus/libgdbus-internal.la $(builtin_libadd) \
@GLIB_LIBS@ @DBUS_LIBS@ -ldl
unit_objects += $(unit_test_rilmodem_sms_OBJECTS)
unit_test_rilmodem_cb_SOURCES = $(test_rilmodem_sources) \
unit/test-rilmodem-cb.c \
drivers/rilmodem/call-barring.c
unit_test_rilmodem_cb_LDADD = gdbus/libgdbus-internal.la $(builtin_libadd) \
@GLIB_LIBS@ @DBUS_LIBS@ -ldl
unit_objects += $(unit_test_rilmodem_cb_OBJECTS)
unit_test_rilmodem_gprs_SOURCES = $(test_rilmodem_sources) \
unit/test-rilmodem-gprs.c \
drivers/rilmodem/gprs.c
unit_test_rilmodem_gprs_LDADD = gdbus/libgdbus-internal.la $(builtin_libadd) \
@GLIB_LIBS@ @DBUS_LIBS@ -ldl
unit_objects += $(unit_test_rilmodem_gprs_OBJECTS)
TESTS = $(unit_tests)
if TOOLS
@@ -851,13 +1114,6 @@ tools_lookup_provider_name_LDADD = @GLIB_LIBS@
tools_tty_redirector_SOURCES = tools/tty-redirector.c
tools_tty_redirector_LDADD = @GLIB_LIBS@
if QMIMODEM
noinst_PROGRAMS += tools/qmi
tools_qmi_SOURCES = $(qmi_sources) tools/qmi.c
tools_qmi_LDADD = @GLIB_LIBS@
endif
if MAINTAINER_MODE
noinst_PROGRAMS += tools/stktest
@@ -926,6 +1182,10 @@ include/ofono/version.h: include/version.h
$(AM_V_at)$(MKDIR_P) include/ofono
$(AM_V_GEN)$(LN_S) $(abs_top_builddir)/$< $@
include/ofono/gdbus.h: $(abs_top_srcdir)/gdbus/gdbus.h
$(AM_V_at)$(MKDIR_P) include/ofono
$(AM_V_GEN)$(LN_S) $< $@
include/ofono/%.h: $(abs_top_srcdir)/include/%.h
$(AM_V_at)$(MKDIR_P) include/ofono
$(AM_V_GEN)$(LN_S) $< $@

View File

@@ -256,6 +256,16 @@ Voicecall
Priority: Medium
Complexity: C1
- DTMF Driver hints
Currently multiple DTMF tones are sent to the driver in batches of up to 8
characters. For those drivers that can only accept a limited set of DTMF
characters at a time (e.g. one), add a setting to the core that will change
this batch size limit.
Priority: Medium
Complexity: C1
Sim Toolkit
===========

View File

@@ -12,7 +12,7 @@ AC_DEFUN([AC_PROG_CC_PIE], [
AC_DEFUN([COMPILER_FLAGS], [
if (test "${CFLAGS}" = ""); then
CFLAGS="-Wall -O2 -D_FORTIFY_SOURCE=2"
CFLAGS="-Wall -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2"
fi
if (test "$USE_MAINTAINER_MODE" = "yes"); then
CFLAGS="$CFLAGS -Werror -Wextra"

View File

@@ -1,5 +1,5 @@
AC_PREREQ(2.60)
AC_INIT(ofono, 1.14)
AC_INIT(ofono, 1.20)
AM_INIT_AUTOMAKE([foreign subdir-objects color-tests])
AC_CONFIG_HEADERS(config.h)
@@ -42,6 +42,7 @@ AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug],
if (test "${enableval}" = "yes" &&
test "${ac_cv_prog_cc_g}" = "yes"); then
CFLAGS="$CFLAGS -g"
CPPFLAGS="$CPPFLAGS -DDEBUG"
fi
])
@@ -63,11 +64,21 @@ AC_CHECK_FUNC(signalfd, dummy=yes,
AC_CHECK_LIB(dl, dlopen, dummy=yes,
AC_MSG_ERROR(dynamic linking loader is required))
PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.28, dummy=yes,
AC_MSG_ERROR(GLib >= 2.28 is required))
PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.32, dummy=yes,
AC_MSG_ERROR(GLib >= 2.32 is required))
AC_SUBST(GLIB_CFLAGS)
AC_SUBST(GLIB_LIBS)
PKG_CHECK_MODULES(GOBJECT, gobject-2.0, dummy=yes,
AC_MSG_ERROR(GObject is required))
GLIB_CFLAGS="$GLIB_CFLAGS $GOBJECT_CFLAGS"
GLIB_LIBS="$GLIB_LIBS $GOBJECT_LIBS"
PKG_CHECK_MODULES(GIO, gio-2.0, dummy=yes,
AC_MSG_ERROR(GIO is required))
GLIB_CFLAGS="$GLIB_CFLAGS $GIO_CFLAGS"
GLIB_LIBS="$GLIB_LIBS $GIO_LIBS"
if (test "${enable_threads}" = "yes"); then
AC_DEFINE(NEED_THREADS, 1, [Define if threading support is required])
PKG_CHECK_MODULES(GTHREAD, gthread-2.0 >= 2.16, dummy=yes,
@@ -166,6 +177,51 @@ AC_ARG_ENABLE(rilmodem, AC_HELP_STRING([--disable-rilmodem],
[enable_rilmodem=${enableval}])
AM_CONDITIONAL(RILMODEM, test "${enable_rilmodem}" != "no")
AC_ARG_ENABLE(sailfish-rilmodem, AC_HELP_STRING([--enable-sailfish-rilmodem],
[enable Sailfish RIL modem]),
[enable_sailfish_rilmodem=${enableval}],
[enable_sailfish_rilmodem="no"])
AM_CONDITIONAL(SAILFISH_RILMODEM, test "${enable_sailfish_rilmodem}" != "no")
if (test "${enable_sailfish_rilmodem}" = "yes"); then
PKG_CHECK_MODULES(GRILIO, libgrilio >= 1.0.20, dummy=yes,
AC_MSG_ERROR(libgrilio >= 1.0.20 is required))
PKG_CHECK_MODULES(GLIBUTIL, libglibutil >= 1.0.23, dummy=yes,
AC_MSG_ERROR(libglibutil >= 1.0.23 is required))
PKG_CHECK_MODULES(LIBMCE, libmce-glib >= 1.0.5, dummy=yes,
AC_MSG_ERROR(libmce-glib >= 1.0.5 is required))
CFLAGS="$CFLAGS $GRILIO_CFLAGS $LIBMCE_CFLAGS"
LIBS="$LIBS $GRILIO_LIBS $LIBMCE_LIBS"
enable_sailfish_manager=yes
need_glibutil=yes
fi
AC_ARG_ENABLE(sailfish-manager,
AC_HELP_STRING([--enable-sailfish-manager],
[enable Sailfish OS modem manager plugin]),
[enable_sailfish_manager=${enableval}])
AM_CONDITIONAL(SAILFISH_MANAGER, test "${enable_sailfish_manager}" = "yes")
if (test "${enable_sailfish_manager}" = "yes"); then
PKG_CHECK_MODULES(DBUS_GLIB, dbus-glib-1, dummy=yes,
AC_MSG_ERROR(dbus-glib is required by unit tests))
AC_SUBST(DBUS_GLIB_CFLAGS)
AC_SUBST(DBUS_GLIB_LIBS)
fi
AC_ARG_ENABLE(add-remove-context, AC_HELP_STRING([--disable-add-remove-context],
[don't allow to add or remove connection context over D-Bus]), [
if (test "${enableval}" = "no"); then
CFLAGS="$CFLAGS -DDISABLE_ADD_REMOVE_CONTEXT"
fi
])
AC_ARG_ENABLE(test-coverage,
AC_HELP_STRING([--enable-test-coverage], [enable test code coverage]),
[enable_test_coverage=${enableval}],
[enable_test_coverage="no"])
AM_CONDITIONAL(TEST_COVERAGE, test "${enable_test_coverage}" != "no")
AC_ARG_ENABLE(qmimodem, AC_HELP_STRING([--disable-qmimodem],
[disable Qualcomm QMI modem support]),
[enable_qmimodem=${enableval}])
@@ -189,6 +245,16 @@ fi
AM_CONDITIONAL(BLUEZ4, test "${enable_bluetooth}" != "no" && test "${enable_bluez4}" = "yes")
AM_CONDITIONAL(BLUETOOTH, test "${enable_bluetooth}" != "no")
AC_ARG_ENABLE(sailfish-bt, AC_HELP_STRING([--enable-sailfish-bt],
[enable Sailfish OS Bluetooth plugin]),
[enable_sailfish_bt=${enableval}])
AM_CONDITIONAL(SAILFISH_BT, test "${enable_sailfish_bt}" = "yes")
AC_ARG_ENABLE(sailfish-provision, AC_HELP_STRING([--enable-sailfish-provision],
[enable Sailfish OS provisioning plugin]),
[enable_sailfish_provision=${enableval}])
AM_CONDITIONAL(SAILFISH_PROVISION, test "${enable_sailfish_provision=$}" = "yes")
AC_ARG_ENABLE(nettime, AC_HELP_STRING([--disable-nettime],
[disable Nettime plugin]),
[enable_nettime=${enableval}])
@@ -201,7 +267,7 @@ AC_ARG_WITH([provisiondb], AC_HELP_STRING([--with-provisiondb=FILE],
[location of provision database]), [path_provisiondb=${withval}])
AC_ARG_ENABLE(provision, AC_HELP_STRING([--disable-provision],
[disable provisioning suport]),
[disable provisioning support]),
[enable_provision=${enableval}])
if (test "${enable_provision}" != "no"); then
if (test -n "${path_provisiondb}"); then
@@ -221,20 +287,46 @@ if (test "${enable_provision}" != "no"); then
fi
AM_CONDITIONAL(PROVISION, test "${enable_provision}" != "no")
AC_ARG_ENABLE(upower, AC_HELP_STRING([--disable-upower],
[disable UPower plugin]),
[enable_upower=${enableval}])
AM_CONDITIONAL(UPOWER, test "${enable_power}" != "no")
AC_ARG_ENABLE(datafiles, AC_HELP_STRING([--disable-datafiles],
[do not install configuration and data files]),
[enable_datafiles=${enableval}])
AM_CONDITIONAL(DATAFILES, test "${enable_datafiles}" != "no")
AC_ARG_ENABLE(pushforwarder, AC_HELP_STRING([--disable-pushforwarder],
[disable Push Forwarder plugin]),
[enable_pushforwarder=${enableval}])
AM_CONDITIONAL(PUSHFORWARDER, test "${enable_pushforwarder}" != "no")
if (test "${enable_pushforwarder}" != "no"); then
AC_ARG_ENABLE(sailfish-pushforwarder, AC_HELP_STRING([--enable-sailfish-pushforwarder],
[enable Sailfish OS push forwarder plugin]),
[enable_sailfish_pushforwarder=${enableval}],
[enable_sailfish_pushforwarder="no"])
AM_CONDITIONAL(SAILFISH_PUSHFORWARDER, test "${enable_sailfish_pushforwarder}" != "no")
if (test "${enable_sailfish_pushforwarder}" != "no"); then
PKG_CHECK_MODULES(GLIBUTIL, libglibutil >= 1.0.15, dummy=yes,
AC_MSG_ERROR(libglibutil >= 1.0.15 is required))
PKG_CHECK_MODULES(WSPCODEC, libwspcodec >= 2.0, dummy=yes,
AC_MSG_ERROR(WSP decoder is required))
AC_SUBST(WSPCODEC_CFLAGS)
AC_SUBST(WSPCODEC_LIBS)
AC_MSG_ERROR(WSP decoder is required))
CFLAGS="$CFLAGS $WSPCODEC_CFLAGS"
LIBS="$LIBS $WSPCODEC_LIBS"
need_glibutil=yes
fi
AC_ARG_ENABLE(sailfish-debuglog, AC_HELP_STRING([--enable-sailfish-debuglog],
[enable Sailfish OS debug log plugin]),
[enable_sailfish_debuglog=${enableval}],
[enable_sailfish_debuglog="no"])
AM_CONDITIONAL(SAILFISH_DEBUGLOG, test "${enable_sailfish_debuglog}" != "no")
if (test "${enable_sailfish_debuglog}" = "yes"); then
PKG_CHECK_MODULES(DBUSLOG, libdbuslogserver-dbus, dummy=yes,
AC_MSG_ERROR(libdbuslogserver-dbus is required))
CFLAGS="$CFLAGS $DBUSLOG_CFLAGS"
LIBS="$LIBS $DBUSLOG_LIBS"
fi
if (test "${need_glibutil}" = "yes"); then
CFLAGS="$CFLAGS $GLIBUTIL_CFLAGS"
LIBS="$LIBS $GLIBUTIL_LIBS"
fi
if (test "${prefix}" = "NONE"); then
@@ -251,7 +343,7 @@ if (test "$localstatedir" = '${prefix}/var'); then
else
storagedir="${localstatedir}/lib/ofono"
fi
AC_DEFINE_UNQUOTED(STORAGEDIR, "${storagedir}",
AC_DEFINE_UNQUOTED(DEFAULT_STORAGEDIR, "${storagedir}",
[Directory for the storage files])
if (test "$sysconfdir" = '${prefix}/etc'); then

View File

@@ -0,0 +1,17 @@
Allowed APNs hierarchy
=========================
Service org.ofono
Interface org.ofono.AllowedAccessPoints
Object path [variable prefix]/{modem0,modem1,...}
Methods array{string} GetAllowedAccessPoints()
Get the list of allowed access points provided
in the SIM card.
This method returns an array of strings which
contains a list of Access Point Names supported
by network provider. Returns with an error if
SIM reading failed or an empty list if there
are no access points listed on the SIM.

View File

@@ -19,7 +19,7 @@ Besides the kernel coding style above, oFono has special flavors for its own.
Some of them are mandatory (marked as 'M'), while some others are optional
(marked as 'O'), but generally preferred.
M1: Blank line before and after an if/while/do/for statement
M1: Blank line before and after an if/while/do/for/switch statement
============================================================
There should be a blank line before if statement unless the if is nested and
not preceded by an expression or variable declaration.
@@ -306,6 +306,13 @@ Example:
2)
0x1 << y // Wrong
M17: Avoid forward-declaration of static functions
==================================================
Functions that are static should not be forward-declared. The only exception
to this rule is if a circular dependency condition exists, and the forward
declaration cannot be avoided.
O1: Shorten the name
====================
Better to use abbreviation, rather than full name, to name a variable,

View File

@@ -60,6 +60,16 @@ Methods dict GetProperties()
[service].Error.NotFound
[service].Error.Failed
void ResetContexts()
Removes all contexts and re-provisions from the APN
database. Contexts must all be deactivated for this
method to work, and the atom must not be powered.
Possible Errors: [service].Error.InProgress
[service].Error.InvalidArguments
[service].Error.NotAllowed
Signals PropertyChanged(string property, variant value)
This signal indicates a changed value of the given
@@ -96,7 +106,7 @@ Properties boolean Attached [readonly]
GPRS service registration (if known).
Possible values are:
"none", "gsm", "edge", "umts", "hsdpa", "hsupa",
"none", "gprs", "edge", "umts", "hsdpa", "hsupa",
"hspa" (HSDPA and HSUPA at the same time) and
"lte"
@@ -155,6 +165,15 @@ Methods dict GetProperties()
[service].Error.AttachInProgress
[service].Error.NotImplemented
Methods void ProvisionContext()
Resets all properties back to default. Fails to make
any changes to the context if it is active or in the
process of being activated or deactivated.
Possible Errors: [service].Error.Failed
[service].Error.InProgress
[service].Error.NotAvailable
Signals PropertyChanged(string property, variant value)
This signal indicates a changed value of the given
@@ -180,6 +199,10 @@ Properties boolean Active [readwrite]
"wap" - Used by WAP related services
"ims" - Used by IMS related services
string AuthenticationMethod [readwrite]
Holds the PPP authentication method to use. Valid
values are "pap" and "chap". Defaults to "chap".
string Username [readwrite]
Holds the username to be used for authentication

View File

@@ -19,6 +19,8 @@ Methods dict GetProperties()
Possible Errors: [service].Error.InProgress
[service].Error.InvalidArguments
[service].Error.NotImplemented
[service].Error.NotSupported
string RequestPhoneNumber()
@@ -51,6 +53,7 @@ Properties array{string} Features [readonly]
"private-chat"
"create-multiparty"
"transfer"
"hf-indicators"
boolean InbandRinging [readonly]
@@ -63,7 +66,7 @@ Properties array{string} Features [readonly]
to activate or deactivate the function from the HF, or
the AG could autonomously initiate it.
boolean EchoCancelingNoiseReduction [readwrite]
boolean EchoCancelingNoiseReduction [readwrite, optional]
Non-persistent Boolean property representing whether
echo canceling and noise reduction is enabled in the
@@ -80,3 +83,10 @@ Properties array{string} Features [readonly]
array{string} SubscriberNumbers [readonly]
List of subscriber numbers provided by the AG.
boolean DistractedDrivingReduction [readwrite, optional]
Non-persistent property representing whether
distracted driving reduction mode should be enabled in
the AG. Support for this feature is optional on the
AG.

View File

@@ -76,6 +76,22 @@ Methods dict GetProperties()
[service].Error.NotImplemented
[service].Error.NotAllowed
fd, byte Acquire()
Attempts to establish the SCO audio connection
returning the filedescriptor of the connection and the
codec in use.
Note: Contrary to Connect this does not call
NewConnection so it can be called in a blocking
manner.
Possible Errors: [service].Error.InProgress
[service].Error.Failed
[service].Error.NotAvailable
[service].Error.NotImplemented
[service].Error.NotAllowed
Signals PropertyChanged(string name, variant value)
This signal indicates a changed value of the given
@@ -89,6 +105,10 @@ Properties string RemoteAddress [readonly]
Bluetooth address of the local adapter.
string Type [readonly]
Type of the card. Valid values are "gateway" or
"handsfree".
Handsfree Audio Agent hierarchy [experimental]
===============================

35
ofono/doc/lte-api.txt Normal file
View File

@@ -0,0 +1,35 @@
LongTermEvolution Hierarchy
Service org.ofono
Interface org.ofono.LongTermEvolution
Object path [variable prefix]/{modem0,modem1,...}
Methods dict GetProperties()
Returns all LongTermEvolution configuration properties.
void SetProperty(string property, variant value)
Changes the value of the specified property. Only
properties that are listed as readwrite are
changeable. On success a PropertyChanged signal
will be emitted.
Possible Errors: [service].Error.InProgress
[service].Error.InvalidArguments
[service].Error.Failed
Signals PropertyChanged(string property, variant value)
This signal indicates a changed value of the given
property.
Properties string DefaultAccessPointName [readwrite]
On LongTermEvolution, contexts activate automatically.
This property allows selection of an APN to be used on
next automatic activation.
Setting this property to an empty string clears the
default APN from the modem.

View File

@@ -90,6 +90,11 @@ Properties boolean Powered [readwrite]
"hfp") this corresponds to the Bluetooth Device
Address of the remote device.
string SoftwareVersionNumber [readonly, optional]
String representing the software version number of the
modem device.
array{string} Features [readonly]
List of currently enabled features. It uses simple

View File

@@ -57,6 +57,11 @@ Signals PropertyChanged(string property, variant value)
This signal indicates a changed value of the given
property.
OperatorsChanged(array{object,dict})
Signal that gets emitted when operator list has
changed. It contains the current list of operators.
Properties string Mode [readonly]
The current registration mode. The default of this

View File

@@ -0,0 +1,122 @@
Network Monitor hierarchy
=========================
Service org.ofono
Interface org.ofono.NetworkMonitor
Object path [variable prefix]/{modem0,modem1,...}
Methods a{sv} GetServingCellInformation()
Requests the latest serving cell information and basic
measurements from oFono. The returned value is a
dictionary with the possible key / values documented
below. The type of cell is given by the 'Technology'
property.
Based on the type of cell, the dictionary will contain
additional key/value pairs. If a given key/value pair
is not present, then it is not known or unsupported
by the underlying driver.
Refer to the sections below for which property types
are available, their valid value ranges and
applicability to different cell types.
Network Monitor Property Types
==============================
string Technology
Contains the cell type. Possible values are:
"gsm", "umts", "lte"
uint16 LocationAreaCode [optional, gsm, umts]
Contains the current location area code. Valid range of values is
0-65535.
uint32 CellId [optional, gsm, umts]
Contains the current network cell id. Valid range of values is
0-65535 for gsm and 0-268435455 in umts.
string MobileNetworkCode [optional, gsm, umts]
Contains the MNC of the cell.
string MobileCountryCode [optional, gsm, umts]
Contains the MCC of the cell.
uint16 ARFCN [optional, gsm]
Contains the Absolute Radio Frequency Channel Number. Valid range of
values is 0-1023.
byte ReceivedSignalStrength [optional, gsm]
Contains the received signal strength level in dBm. Refer to <rxlev>
in 27.007, Section 8.69 for more details. Valid range of values is
0-63.
byte BSIC [optional, gsm]
Contains the Base Station Identity Code. Valid range of values is 0-63.
byte BitErrorRate [optional, gsm]
Contains the bit error rate. Refer to <ber> in 27.007, Section 8.69
for more details. Valid range of values is 0-7.
uint16 PrimaryScramblingCode [optional, umts]
Contains the scrambling code. Valid range of values is 0-512.
byte TimingAdvance [optional, gsm]
Contains the Timing Advance. Valid range of values is 0-219.
byte Strength [optional, gsm, umts]
Contains the signal strength. Valid values are 0-31. Refer to <rssi>
in 27.007, Section 8.5.
byte ReceivedSignalCodePower [optional, umts]
Contains the Received Signal Code Power. Valid range of values
is 0-96. Refer to <rscp> in 27.007, Section 8.69 for more details.
byte ReceivedEnergyRatio [optional, umts]
Contains the Ratio of received energy per PN chip to the total
received power spectral density. Valid range of values is 0-49.
Refer to <ecno> in 27.007, Section 8.69 for more details.
byte ReferenceSignalReceivedQuality [optional, lte]
Contains the Reference Signal Received Quality. Valid range of
values is 0-34. Refer to <rsrq> in 27.007, Section 8.69 for more
details.
byte ReferenceSignalReceivedPower [optional, lte]
Contains the Reference Signal Received Power. Valid range of values
is 0-97. Refer to <rsrp> in 27.007, Section 8.69 for more details.
uint16 EARFCN [optional, lte]
Contains E-UTRA Absolute Radio Frequency Channel Number. Valid
range of values is 0-65535. Refer to Carrier frequency and
EARFCN in 36.101, Section 5.7.3 for more details.
byte EBand [optional, lte]
Contains E-UTRA operating Band. Valid range of values is 1-43.
Refer to Operating bands in 36.101, Section 5.5 for more
details.
byte ChannelQualityIndicator [optional, lte]
Contains Channel Quality Indicator. Refer to Channel Quality
Indicator definition in 36.213, Section 7.2.3 for more details.

View File

@@ -45,6 +45,11 @@ Properties string TechnologyPreference [readwrite]
"umts" Only UMTS used for radio access.
"lte" Only LTE used for radio access.
array{string} AvailableTechnologies [readonly, optional]
List of values for TechnologyPreference property
supported by the modem.
string GsmBand [readwrite, optional]
Frequency band in which the modem is allowed to

View File

@@ -93,6 +93,11 @@ Properties boolean Present [readonly]
Contains the IMSI of the SIM, if available.
string ServiceProviderName [readonly, optional]
Contains the service provider name fetched from the
SIM card, if available.
string MobileCountryCode [readonly, optional]
Contains the Mobile Country Code (MCC) of the home

46
ofono/doc/telit-modem.txt Normal file
View File

@@ -0,0 +1,46 @@
oFono - Open Source Telephony
*****************************
Purpose
=======
The purpose of this document is to identify issues and configuration
requirements with Telit's modems.
HE910
=====
GPS:
To enable location reporting on the Telit HE910 the modem needs to be
switched to Port Configuration #8. Please refer to Telit's
'HE910 UE910 Family Ports Arrangements' section 4.1.3 for rationale and
'AT Commands Reference Guide' section 3.5.7.1.96 for specific AT command.
After setting the configuration, a power cycle is required.
Port Configiuration #8 is available since firmware 12.00.004. Firmware version
can be checked using 'AT+CGMR'.
LE910 V2
========
Default USB composition of LE910V2 uses PID 0x36 (AT#PORTCFG=0)
and consists of 6 serial ports (CDC-ACM standard, /dev/ttyACMx)
and 1 network adapter using CDC-NCM standard (wwanx or usbx).
NCM interface configuration follows Telit documentation
(both documents available on Telit Download Zone - registration required)
"GE/HE/UE910, UL865, LE910 V2 Linux USB Driver - User Guide r0"
(document 1VV0301255 Rev.0 - 2016-01-22)
and "Telit LE910-V2 NCM SETUP r3"
(document 1VV0301246 Rev.3 - 2016-11-29).
After context is setup, NCM mode activated and PDP context activated
connection configuration can be read using
AT+CGPADDR=context_id and AT+CGCONTRDP=context_id commands.
This is done automatically and results available via
org.ofono.ConnectionContext.GetProperties DBus method.
Then Linux network interface needs to be configured:
ifconfig <Interface> <Address> netmask <Netmask> up
route add default gw <Gateway>
arp -s <Gateway> 11:22:33:44:55:66
Only after these steps network interface is usable.

View File

@@ -47,6 +47,7 @@
#define STATIC_IP_NETMASK "255.255.255.255"
static const char *cgdata_prefix[] = { "+CGDATA:", NULL };
static const char *none_prefix[] = { NULL };
enum state {
@@ -59,6 +60,7 @@ enum state {
struct gprs_context_data {
GAtChat *chat;
unsigned int active_context;
GAtPPPAuthMethod auth_method;
char username[OFONO_GPRS_MAX_USERNAME_LENGTH + 1];
char password[OFONO_GPRS_MAX_PASSWORD_LENGTH + 1];
GAtPPP *ppp;
@@ -66,6 +68,7 @@ struct gprs_context_data {
ofono_gprs_context_cb_t cb;
void *cb_data; /* Callback data */
unsigned int vendor;
gboolean use_atd99;
};
static void ppp_debug(const char *str, void *data)
@@ -154,6 +157,7 @@ static gboolean setup_ppp(struct ofono_gprs_context *gc)
if (getenv("OFONO_PPP_DEBUG"))
g_at_ppp_set_debug(gcd->ppp, ppp_debug, "PPP");
g_at_ppp_set_auth_method(gcd->ppp, gcd->auth_method);
g_at_ppp_set_credentials(gcd->ppp, gcd->username, gcd->password);
/* set connect and disconnect callbacks */
@@ -208,7 +212,7 @@ static void at_cgdcont_cb(gboolean ok, GAtResult *result, gpointer user_data)
return;
}
if (gcd->vendor == OFONO_VENDOR_SIMCOM_SIM900)
if (gcd->use_atd99)
sprintf(buf, "ATD*99***%u#", gcd->active_context);
else
sprintf(buf, "AT+CGDATA=\"PPP\",%u", gcd->active_context);
@@ -243,6 +247,20 @@ static void at_gprs_activate_primary(struct ofono_gprs_context *gc,
memcpy(gcd->username, ctx->username, sizeof(ctx->username));
memcpy(gcd->password, ctx->password, sizeof(ctx->password));
/* We only support CHAP and PAP */
switch (ctx->auth_method) {
case OFONO_GPRS_AUTH_METHOD_ANY:
case OFONO_GPRS_AUTH_METHOD_NONE:
case OFONO_GPRS_AUTH_METHOD_CHAP:
gcd->auth_method = G_AT_PPP_AUTH_METHOD_CHAP;
break;
case OFONO_GPRS_AUTH_METHOD_PAP:
gcd->auth_method = G_AT_PPP_AUTH_METHOD_PAP;
break;
default:
goto error;
}
gcd->state = STATE_ENABLING;
if (gcd->vendor == OFONO_VENDOR_ZTE) {
@@ -268,9 +286,36 @@ static void at_gprs_activate_primary(struct ofono_gprs_context *gc,
len = snprintf(buf, sizeof(buf), "AT+CGDCONT=%u,\"IP\"", ctx->cid);
if (ctx->apn)
snprintf(buf + len, sizeof(buf) - len - 3, ",\"%s\"",
ctx->apn);
if (ctx->apn) {
switch (gcd->vendor) {
case OFONO_VENDOR_UBLOX:
/*
* U-blox modems require a magic prefix to the APN to
* specify the authentication method to use in the
* network. See UBX-13002752 - R21.
*
* As the response of the read command omits this magic
* prefix, this is the least invasive place to set it.
*/
switch (ctx->auth_method) {
case OFONO_GPRS_AUTH_METHOD_ANY:
case OFONO_GPRS_AUTH_METHOD_NONE:
case OFONO_GPRS_AUTH_METHOD_CHAP:
snprintf(buf + len, sizeof(buf) - len - 3,
",\"CHAP:%s\"", ctx->apn);
break;
case OFONO_GPRS_AUTH_METHOD_PAP:
snprintf(buf + len, sizeof(buf) - len - 3,
",\"PAP:%s\"", ctx->apn);
break;
}
break;
default:
snprintf(buf + len, sizeof(buf) - len - 3, ",\"%s\"",
ctx->apn);
break;
}
}
if (g_at_chat_send(gcd->chat, buf, none_prefix,
at_cgdcont_cb, gc, NULL) > 0)
@@ -339,6 +384,43 @@ static void cgev_notify(GAtResult *result, gpointer user_data)
g_at_ppp_shutdown(gcd->ppp);
}
static void at_cgdata_test_cb(gboolean ok, GAtResult *result,
gpointer user_data)
{
struct ofono_gprs_context *gc = user_data;
struct gprs_context_data *gcd = ofono_gprs_context_get_data(gc);
GAtResultIter iter;
const char *data_type;
gboolean found = FALSE;
gcd->use_atd99 = TRUE;
if (!ok) {
DBG("not ok");
goto error;
}
g_at_result_iter_init(&iter, result);
if (!g_at_result_iter_next(&iter, "+CGDATA:")) {
DBG("no +CGDATA line");
goto error;
}
if (!g_at_result_iter_open_list(&iter)) {
DBG("no list found");
goto error;
}
while (!found && g_at_result_iter_next_string(&iter, &data_type)) {
if (g_str_equal(data_type, "PPP")) {
found = TRUE;
gcd->use_atd99 = FALSE;
}
}
error:
DBG("use_atd99:%d", gcd->use_atd99);
}
static int at_gprs_context_probe(struct ofono_gprs_context *gc,
unsigned int vendor, void *data)
{
@@ -366,6 +448,15 @@ static int at_gprs_context_probe(struct ofono_gprs_context *gc,
if (chat == NULL)
return 0;
switch (vendor) {
case OFONO_VENDOR_SIMCOM_SIM900:
gcd->use_atd99 = FALSE;
break;
default:
g_at_chat_send(chat, "AT+CGDATA=?", cgdata_prefix,
at_cgdata_test_cb, gc, NULL);
}
g_at_chat_register(chat, "+CGEV:", cgev_notify, FALSE, gc, NULL);
return 0;

View File

@@ -49,6 +49,9 @@ static const char *none_prefix[] = { NULL };
struct gprs_data {
GAtChat *chat;
unsigned int vendor;
unsigned int last_auto_context_id;
gboolean telit_try_reattach;
int attached;
};
static void at_cgatt_cb(gboolean ok, GAtResult *result, gpointer user_data)
@@ -72,8 +75,10 @@ static void at_gprs_set_attached(struct ofono_gprs *gprs, int attached,
snprintf(buf, sizeof(buf), "AT+CGATT=%i", attached ? 1 : 0);
if (g_at_chat_send(gd->chat, buf, none_prefix,
at_cgatt_cb, cbd, g_free) > 0)
at_cgatt_cb, cbd, g_free) > 0) {
gd->attached = attached;
return;
}
g_free(cbd);
@@ -141,6 +146,48 @@ static void at_gprs_registration_status(struct ofono_gprs *gprs,
CALLBACK_WITH_FAILURE(cb, -1, data);
}
static void at_cgdcont_read_cb(gboolean ok, GAtResult *result,
gpointer user_data)
{
struct ofono_gprs *gprs = user_data;
struct gprs_data *gd = ofono_gprs_get_data(gprs);
int activated_cid = gd->last_auto_context_id;
const char *apn = NULL;
GAtResultIter iter;
DBG("ok %d", ok);
if (!ok) {
ofono_warn("Can't read CGDCONT contexts.");
return;
}
g_at_result_iter_init(&iter, result);
while (g_at_result_iter_next(&iter, "+CGDCONT:")) {
int read_cid;
if (!g_at_result_iter_next_number(&iter, &read_cid))
break;
if (read_cid != activated_cid)
continue;
/* ignore protocol */
g_at_result_iter_skip_next(&iter);
g_at_result_iter_next_string(&iter, &apn);
break;
}
if (apn)
ofono_gprs_cid_activated(gprs, activated_cid, apn);
else
ofono_warn("cid %u: Received activated but no apn present",
activated_cid);
}
static void cgreg_notify(GAtResult *result, gpointer user_data)
{
struct ofono_gprs *gprs = user_data;
@@ -151,12 +198,35 @@ static void cgreg_notify(GAtResult *result, gpointer user_data)
NULL, NULL, NULL, gd->vendor) == FALSE)
return;
/*
* Telit AT modem firmware (tested with UE910-EUR) generates
* +CGREG: 0\r\n\r\n+CGEV: NW DETACH
* after a context is de-activated and ppp connection closed.
* Then, after a random amount of time (observed from a few seconds
* to a few hours), an unsolicited +CGREG: 1 arrives.
* Attempt to fix the problem, by sending AT+CGATT=1 once.
* This does not re-activate the context, but if a network connection
* is still correct, will generate an immediate +CGREG: 1.
*/
if (gd->vendor == OFONO_VENDOR_TELIT) {
if (gd->attached && !status && !gd->telit_try_reattach) {
DBG("Trying to re-attach gprs network");
gd->telit_try_reattach = TRUE;
g_at_chat_send(gd->chat, "AT+CGATT=1", none_prefix,
NULL, NULL, NULL);
return;
}
gd->telit_try_reattach = FALSE;
}
ofono_gprs_status_notify(gprs, status);
}
static void cgev_notify(GAtResult *result, gpointer user_data)
{
struct ofono_gprs *gprs = user_data;
struct gprs_data *gd = ofono_gprs_get_data(gprs);
GAtResultIter iter;
const char *event;
@@ -170,8 +240,18 @@ static void cgev_notify(GAtResult *result, gpointer user_data)
if (g_str_equal(event, "NW DETACH") ||
g_str_equal(event, "ME DETACH")) {
if (gd->vendor == OFONO_VENDOR_TELIT &&
gd->telit_try_reattach)
return;
gd->attached = FALSE;
ofono_gprs_detached_notify(gprs);
return;
} else if (g_str_has_prefix(event, "ME PDN ACT")) {
sscanf(event, "%*s %*s %*s %u", &gd->last_auto_context_id);
g_at_chat_send(gd->chat, "AT+CGDCONT?", cgdcont_prefix,
at_cgdcont_read_cb, gprs, NULL);
}
}
@@ -274,6 +354,9 @@ static void telit_mode_notify(GAtResult *result, gpointer user_data)
case 3:
bearer = 5; /* HSDPA */
break;
case 4:
bearer = 7; /* LTE */
break;
default:
bearer = 0;
break;
@@ -282,6 +365,40 @@ static void telit_mode_notify(GAtResult *result, gpointer user_data)
ofono_gprs_bearer_notify(gprs, bearer);
}
static void ublox_ureg_notify(GAtResult *result, gpointer user_data)
{
struct ofono_gprs *gprs = user_data;
GAtResultIter iter;
gint state, bearer;
g_at_result_iter_init(&iter, result);
if (!g_at_result_iter_next(&iter, "+UREG:"))
return;
if (!g_at_result_iter_next_number(&iter, &state))
return;
switch (state) {
case 4:
bearer = 5;
break;
case 5:
bearer = 4;
break;
case 8:
bearer = 1;
break;
case 9:
bearer = 2;
break;
default:
bearer = state;
}
ofono_gprs_bearer_notify(gprs, bearer);
}
static void cpsb_notify(GAtResult *result, gpointer user_data)
{
struct ofono_gprs *gprs = user_data;
@@ -316,6 +433,13 @@ static void gprs_initialized(gboolean ok, GAtResult *result, gpointer user_data)
g_at_chat_register(gd->chat, "^MODE:", huawei_mode_notify,
FALSE, gprs, NULL);
break;
case OFONO_VENDOR_UBLOX:
case OFONO_VENDOR_UBLOX_TOBY_L2:
g_at_chat_register(gd->chat, "+UREG:", ublox_ureg_notify,
FALSE, gprs, NULL);
g_at_chat_send(gd->chat, "AT+UREG=1", none_prefix,
NULL, NULL, NULL);
break;
case OFONO_VENDOR_TELIT:
g_at_chat_register(gd->chat, "#PSNT:", telit_mode_notify,
FALSE, gprs, NULL);
@@ -432,7 +556,7 @@ static void at_cgdcont_test_cb(gboolean ok, GAtResult *result,
if (g_at_result_iter_next_range(&iter, &min, &max) == FALSE)
continue;
if (!g_at_result_iter_close_list(&iter))
if (!g_at_result_iter_skip_next(&iter))
continue;
if (g_at_result_iter_open_list(&iter))

View File

@@ -838,6 +838,39 @@ static void telit_ciev_notify(GAtResult *result, gpointer user_data)
ofono_netreg_strength_notify(netreg, strength);
}
static void cinterion_ciev_notify(GAtResult *result, gpointer user_data)
{
struct ofono_netreg *netreg = user_data;
struct netreg_data *nd = ofono_netreg_get_data(netreg);
const char *signal_identifier = "rssi";
const char *ind_str;
int strength;
GAtResultIter iter;
g_at_result_iter_init(&iter, result);
if (!g_at_result_iter_next(&iter, "+CIEV:"))
return;
if (!g_at_result_iter_next_unquoted_string(&iter, &ind_str))
return;
if (!g_str_equal(signal_identifier, ind_str))
return;
if (!g_at_result_iter_next_number(&iter, &strength))
return;
DBG("rssi %d", strength);
if (strength == nd->signal_invalid)
strength = -1;
else
strength = (strength * 100) / (nd->signal_max - nd->signal_min);
ofono_netreg_strength_notify(netreg, strength);
}
static void ctzv_notify(GAtResult *result, gpointer user_data)
{
struct ofono_netreg *netreg = user_data;
@@ -1547,17 +1580,28 @@ static inline ofono_bool_t append_cmer_element(char *buf, int *len, int cap,
static ofono_bool_t build_cmer_string(char *buf, int *cmer_opts,
struct netreg_data *nd)
{
const char *mode;
const char *ind;
int len = sprintf(buf, "AT+CMER=");
const char *mode;
DBG("");
switch (nd->vendor) {
case OFONO_VENDOR_UBLOX_TOBY_L2:
/* UBX-13002752 R33: TOBY L2 doesn't support mode 2 and 3 */
mode = "1";
break;
default:
mode = "3";
break;
}
/*
* Forward unsolicited result codes directly to the TE;
* TATE link specific inband technique used to embed result codes and
* data when TA is in online data mode
*/
if (!append_cmer_element(buf, &len, cmer_opts[0], "3", FALSE))
if (!append_cmer_element(buf, &len, cmer_opts[0], mode, FALSE))
return FALSE;
/* No keypad event reporting */
@@ -1574,14 +1618,14 @@ static ofono_bool_t build_cmer_string(char *buf, int *cmer_opts,
* Telit does not support mode 1.
* All indicator events shall be directed from TA to TE.
*/
mode = "2";
ind = "2";
break;
default:
/*
* Only those indicator events, which are not caused by +CIND
* shall be indicated by the TA to the TE.
*/
mode = "1";
ind = "1";
break;
}
@@ -1590,7 +1634,7 @@ static ofono_bool_t build_cmer_string(char *buf, int *cmer_opts,
* <ind> indicates the indicator order number (as specified for +CIND)
* and <value> is the new value of indicator.
*/
if (!append_cmer_element(buf, &len, cmer_opts[3], mode, TRUE))
if (!append_cmer_element(buf, &len, cmer_opts[3], ind, TRUE))
return FALSE;
return TRUE;
@@ -1915,6 +1959,27 @@ static void at_creg_set_cb(gboolean ok, GAtResult *result, gpointer user_data)
g_at_chat_send(nd->chat, "AT*TLTS=1", none_prefix,
NULL, NULL, NULL);
break;
case OFONO_VENDOR_CINTERION:
/*
* We can't set rssi bounds from Cinterion responses
* so set them up to specified values here
*
* Cinterion rssi signal strength specified as:
* 0 <= -112dBm
* 1 - 4 signal strengh in 15 dB steps
* 5 >= -51 dBm
* 99 not known or undetectable
*/
nd->signal_min = 0;
nd->signal_max = 5;
nd->signal_invalid = 99;
/* Register for specific signal strength reports */
g_at_chat_send(nd->chat, "AT^SIND=\"rssi\",1", none_prefix,
NULL, NULL, NULL);
g_at_chat_register(nd->chat, "+CIEV:",
cinterion_ciev_notify, FALSE, netreg, NULL);
break;
case OFONO_VENDOR_NOKIA:
case OFONO_VENDOR_SAMSUNG:
/* Signal strength reporting via CIND is not supported */

View File

@@ -51,6 +51,7 @@ struct sim_data {
GAtChat *chat;
unsigned int vendor;
guint ready_id;
guint passwd_type_mask;
struct at_util_sim_state_query *sim_state_query;
};
@@ -67,6 +68,8 @@ static const char *epin_prefix[] = { "*EPIN:", NULL };
static const char *spic_prefix[] = { "+SPIC:", NULL };
static const char *pct_prefix[] = { "#PCT:", NULL };
static const char *pnnm_prefix[] = { "+PNNM:", NULL };
static const char *qpinc_prefix[] = { "+QPINC:", NULL };
static const char *upincnt_prefix[] = { "+UPINCNT:", NULL };
static const char *none_prefix[] = { NULL };
static void at_crsm_info_cb(gboolean ok, GAtResult *result, gpointer user_data)
@@ -825,7 +828,7 @@ static void at_cpinr_cb(gboolean ok, GAtResult *result, gpointer user_data)
for (i = 1; i < len; i++) {
if (!strcmp(name, at_sim_name[i].name)) {
retries[i] = val;
retries[at_sim_name[i].type] = val;
break;
}
}
@@ -967,6 +970,90 @@ error:
CALLBACK_WITH_FAILURE(cb, NULL, cbd->data);
}
static void at_qpinc_cb(gboolean ok, GAtResult *result, gpointer user_data)
{
struct cb_data *cbd = user_data;
ofono_sim_pin_retries_cb_t cb = cbd->cb;
const char *final = g_at_result_final_response(result);
GAtResultIter iter;
struct ofono_error error;
int retries[OFONO_SIM_PASSWORD_INVALID];
size_t i;
decode_at_error(&error, final);
if (!ok) {
cb(&error, NULL, cbd->data);
return;
}
for (i = 0; i < OFONO_SIM_PASSWORD_INVALID; i++)
retries[i] = -1;
g_at_result_iter_init(&iter, result);
while (g_at_result_iter_next(&iter, "+QPINC:")) {
const char *name;
int pin, puk;
if (!g_at_result_iter_next_string(&iter, &name))
continue;
if (!g_at_result_iter_next_number(&iter, &pin))
continue;
if (!g_at_result_iter_next_number(&iter, &puk))
continue;
if (!strcmp(name, "SC")) {
retries[OFONO_SIM_PASSWORD_SIM_PIN] = pin;
retries[OFONO_SIM_PASSWORD_SIM_PUK] = puk;
} else if (!strcmp(name, "P2")) {
retries[OFONO_SIM_PASSWORD_SIM_PIN2] = pin;
retries[OFONO_SIM_PASSWORD_SIM_PUK2] = puk;
}
}
cb(&error, retries, cbd->data);
}
static void upincnt_cb(gboolean ok, GAtResult *result, gpointer user_data)
{
struct cb_data *cbd = user_data;
ofono_sim_pin_retries_cb_t cb = cbd->cb;
const char *final = g_at_result_final_response(result);
GAtResultIter iter;
struct ofono_error error;
int retries[OFONO_SIM_PASSWORD_INVALID];
size_t i;
static enum ofono_sim_password_type password_types[] = {
OFONO_SIM_PASSWORD_SIM_PIN,
OFONO_SIM_PASSWORD_SIM_PIN2,
OFONO_SIM_PASSWORD_SIM_PUK,
OFONO_SIM_PASSWORD_SIM_PUK2,
};
decode_at_error(&error, final);
if (!ok) {
cb(&error, NULL, cbd->data);
return;
}
g_at_result_iter_init(&iter, result);
if (!g_at_result_iter_next(&iter, "+UPINCNT:"))
goto error;
BUILD_PIN_RETRIES_ARRAY(password_types, ARRAY_SIZE(password_types),
retries);
cb(&error, retries, cbd->data);
return;
error:
CALLBACK_WITH_FAILURE(cb, NULL, cbd->data);
}
static void at_pin_retries_query(struct ofono_sim *sim,
ofono_sim_pin_retries_cb_t cb,
void *data)
@@ -1028,6 +1115,17 @@ static void at_pin_retries_query(struct ofono_sim *sim,
at_pnnm_cb, cbd, g_free) > 0)
return;
break;
case OFONO_VENDOR_QUECTEL:
if (g_at_chat_send(sd->chat, "AT+QPINC?", qpinc_prefix,
at_qpinc_cb, cbd, g_free) > 0)
return;
break;
case OFONO_VENDOR_UBLOX:
case OFONO_VENDOR_UBLOX_TOBY_L2:
if (g_at_chat_send(sd->chat, "AT+UPINCNT", upincnt_prefix,
upincnt_cb, cbd, g_free) > 0)
return;
break;
default:
if (g_at_chat_send(sd->chat, "AT+CPINR", cpinr_prefixes,
at_cpinr_cb, cbd, g_free) > 0)
@@ -1196,14 +1294,15 @@ static void sim_state_cb(gboolean present, gpointer user_data)
struct cb_data *cbd = user_data;
struct sim_data *sd = cbd->user;
ofono_sim_lock_unlock_cb_t cb = cbd->cb;
void *data = cbd->data;
at_util_sim_state_query_free(sd->sim_state_query);
sd->sim_state_query = NULL;
if (present == 1)
CALLBACK_WITH_SUCCESS(cb, cbd->data);
CALLBACK_WITH_SUCCESS(cb, data);
else
CALLBACK_WITH_FAILURE(cb, cbd->data);
CALLBACK_WITH_FAILURE(cb, data);
}
static void at_pin_send_cb(gboolean ok, GAtResult *result,
@@ -1254,6 +1353,7 @@ static void at_pin_send_cb(gboolean ok, GAtResult *result,
case OFONO_VENDOR_ALCATEL:
case OFONO_VENDOR_HUAWEI:
case OFONO_VENDOR_SIMCOM:
case OFONO_VENDOR_SIERRA:
/*
* On ZTE modems, after pin is entered, SIM state is checked
* by polling CPIN as their modem doesn't provide unsolicited
@@ -1360,9 +1460,8 @@ static void at_pin_enable(struct ofono_sim *sim,
struct cb_data *cbd = cb_data_new(cb, data);
char buf[64];
int ret;
unsigned int len = sizeof(at_clck_cpwd_fac) / sizeof(*at_clck_cpwd_fac);
if (passwd_type >= len || at_clck_cpwd_fac[passwd_type] == NULL)
if (!(sd->passwd_type_mask & (1 << passwd_type)))
goto error;
snprintf(buf, sizeof(buf), "AT+CLCK=\"%s\",%i,\"%s\"",
@@ -1391,10 +1490,8 @@ static void at_change_passwd(struct ofono_sim *sim,
struct cb_data *cbd = cb_data_new(cb, data);
char buf[64];
int ret;
unsigned int len = sizeof(at_clck_cpwd_fac) / sizeof(*at_clck_cpwd_fac);
if (passwd_type >= len ||
at_clck_cpwd_fac[passwd_type] == NULL)
if (!(sd->passwd_type_mask & (1 << passwd_type)))
goto error;
snprintf(buf, sizeof(buf), "AT+CPWD=\"%s\",\"%s\",\"%s\"",
@@ -1419,7 +1516,7 @@ static void at_lock_status_cb(gboolean ok, GAtResult *result,
{
struct cb_data *cbd = user_data;
GAtResultIter iter;
ofono_sim_locked_cb_t cb = cbd->cb;
ofono_query_facility_lock_cb_t cb = cbd->cb;
struct ofono_error error;
int locked;
@@ -1444,16 +1541,15 @@ static void at_lock_status_cb(gboolean ok, GAtResult *result,
cb(&error, locked, cbd->data);
}
static void at_pin_query_enabled(struct ofono_sim *sim,
static void at_query_clck(struct ofono_sim *sim,
enum ofono_sim_password_type passwd_type,
ofono_sim_locked_cb_t cb, void *data)
ofono_query_facility_lock_cb_t cb, void *data)
{
struct sim_data *sd = ofono_sim_get_data(sim);
struct cb_data *cbd = cb_data_new(cb, data);
char buf[64];
unsigned int len = sizeof(at_clck_cpwd_fac) / sizeof(*at_clck_cpwd_fac);
if (passwd_type >= len || at_clck_cpwd_fac[passwd_type] == NULL)
if (!(sd->passwd_type_mask & (1 << passwd_type)))
goto error;
snprintf(buf, sizeof(buf), "AT+CLCK=\"%s\",2",
@@ -1469,13 +1565,42 @@ error:
CALLBACK_WITH_FAILURE(cb, -1, data);
}
static gboolean at_sim_register(gpointer user)
static void at_clck_query_cb(gboolean ok, GAtResult *result, gpointer user)
{
struct ofono_sim *sim = user;
struct sim_data *sd = ofono_sim_get_data(sim);
GAtResultIter iter;
const char *fac;
if (!ok)
goto done;
g_at_result_iter_init(&iter, result);
/* e.g. +CLCK: ("SC","FD","PN","PU","PP","PC","PF") */
if (!g_at_result_iter_next(&iter, "+CLCK:") ||
!g_at_result_iter_open_list(&iter))
goto done;
/* Clear the default mask */
sd->passwd_type_mask = 0;
/* Set the bits for <fac>s that are actually supported */
while (g_at_result_iter_next_string(&iter, &fac)) {
unsigned int i;
/* Find it in the list of known <fac>s */
for (i = 0; i < ARRAY_SIZE(at_clck_cpwd_fac); i++) {
if (!g_strcmp0(at_clck_cpwd_fac[i], fac)) {
sd->passwd_type_mask |= (1 << i);
DBG("found %s", fac);
break;
}
}
}
done:
ofono_sim_register(sim);
return FALSE;
}
static int at_sim_probe(struct ofono_sim *sim, unsigned int vendor,
@@ -1483,6 +1608,7 @@ static int at_sim_probe(struct ofono_sim *sim, unsigned int vendor,
{
GAtChat *chat = data;
struct sim_data *sd;
unsigned int i;
sd = g_new0(struct sim_data, 1);
sd->chat = g_at_chat_clone(chat);
@@ -1492,9 +1618,15 @@ static int at_sim_probe(struct ofono_sim *sim, unsigned int vendor,
g_at_chat_send(sd->chat, "AT*EPEE=1", NULL, NULL, NULL, NULL);
ofono_sim_set_data(sim, sd);
g_idle_add(at_sim_register, sim);
return 0;
/* <fac>s supported by default */
for (i = 0; i < ARRAY_SIZE(at_clck_cpwd_fac); i++)
if (at_clck_cpwd_fac[i])
sd->passwd_type_mask |= (1 << i);
/* Query supported <fac>s */
return g_at_chat_send(sd->chat, "AT+CLCK=?", clck_prefix,
at_clck_query_cb, sim, NULL) ? 0 : -1;
}
static void at_sim_remove(struct ofono_sim *sim)
@@ -1529,7 +1661,7 @@ static struct ofono_sim_driver driver = {
.reset_passwd = at_pin_send_puk,
.lock = at_pin_enable,
.change_passwd = at_change_passwd,
.query_locked = at_pin_query_enabled,
.query_facility_lock = at_query_clck,
};
static struct ofono_sim_driver driver_noef = {
@@ -1543,7 +1675,7 @@ static struct ofono_sim_driver driver_noef = {
.reset_passwd = at_pin_send_puk,
.lock = at_pin_enable,
.change_passwd = at_change_passwd,
.query_locked = at_pin_query_enabled,
.query_facility_lock = at_query_clck,
};
void at_sim_init(void)

View File

@@ -319,26 +319,6 @@ static void at_cnma_cb(gboolean ok, GAtResult *result, gpointer user_data)
"Further SMS reception is not guaranteed");
}
static gboolean at_parse_cmt(GAtResult *result, const char **pdu, int *pdulen)
{
GAtResultIter iter;
g_at_result_iter_init(&iter, result);
if (!g_at_result_iter_next(&iter, "+CMT:"))
return FALSE;
if (!g_at_result_iter_skip_next(&iter))
return FALSE;
if (!g_at_result_iter_next_number(&iter, pdulen))
return FALSE;
*pdu = g_at_result_pdu(result);
return TRUE;
}
static inline void at_ack_delivery(struct ofono_sms *sms)
{
struct sms_data *data = ofono_sms_get_data(sms);
@@ -347,11 +327,21 @@ static inline void at_ack_delivery(struct ofono_sms *sms)
DBG("");
/* We must acknowledge the PDU using CNMA */
if (data->cnma_ack_pdu)
snprintf(buf, sizeof(buf), "AT+CNMA=1,%d\r%s",
data->cnma_ack_pdu_len, data->cnma_ack_pdu);
else /* Should be a safe fallback */
if (data->cnma_ack_pdu) {
switch (data->vendor) {
case OFONO_VENDOR_CINTERION:
snprintf(buf, sizeof(buf), "AT+CNMA=1");
break;
default:
snprintf(buf, sizeof(buf), "AT+CNMA=1,%d\r%s",
data->cnma_ack_pdu_len,
data->cnma_ack_pdu);
break;
}
} else {
/* Should be a safe fallback */
snprintf(buf, sizeof(buf), "AT+CNMA=0");
}
g_at_chat_send(data->chat, buf, none_prefix, at_cnma_cb, NULL, NULL);
}
@@ -409,16 +399,34 @@ static void at_cmt_notify(GAtResult *result, gpointer user_data)
{
struct ofono_sms *sms = user_data;
struct sms_data *data = ofono_sms_get_data(sms);
GAtResultIter iter;
const char *hexpdu;
unsigned char pdu[176];
long pdu_len;
int tpdu_len;
unsigned char pdu[176];
if (!at_parse_cmt(result, &hexpdu, &tpdu_len)) {
ofono_error("Unable to parse CMT notification");
return;
g_at_result_iter_init(&iter, result);
if (!g_at_result_iter_next(&iter, "+CMT:"))
goto err;
switch (data->vendor) {
case OFONO_VENDOR_CINTERION:
if (!g_at_result_iter_next_number(&iter, &tpdu_len))
goto err;
break;
default:
if (!g_at_result_iter_skip_next(&iter))
goto err;
if (!g_at_result_iter_next_number(&iter, &tpdu_len))
goto err;
break;
}
hexpdu = g_at_result_pdu(result);
if (strlen(hexpdu) > sizeof(pdu) * 2) {
ofono_error("Bad PDU length in CMT notification");
return;
@@ -431,6 +439,9 @@ static void at_cmt_notify(GAtResult *result, gpointer user_data)
if (data->vendor != OFONO_VENDOR_SIMCOM)
at_ack_delivery(sms);
err:
ofono_error("Unable to parse CMT notification");
}
static void at_cmgr_notify(GAtResult *result, gpointer user_data)
@@ -742,7 +753,7 @@ static void at_sms_initialized(struct ofono_sms *sms)
static void at_sms_not_supported(struct ofono_sms *sms)
{
ofono_error("SMS not supported by this modem. If this is in error"
ofono_error("SMS not supported by this modem. If this is an error"
" please submit patches to support this hardware");
ofono_sms_remove(sms);

View File

@@ -42,5 +42,9 @@ enum ofono_vendor {
OFONO_VENDOR_SIMCOM_SIM900,
OFONO_VENDOR_ICERA,
OFONO_VENDOR_WAVECOM_Q2XXX,
OFONO_VENDOR_ALCATEL
OFONO_VENDOR_ALCATEL,
OFONO_VENDOR_QUECTEL,
OFONO_VENDOR_UBLOX,
OFONO_VENDOR_UBLOX_TOBY_L2,
OFONO_VENDOR_CINTERION,
};

View File

@@ -253,8 +253,7 @@ static void clcc_poll_cb(gboolean ok, GAtResult *result, gpointer user_data)
}
}
g_slist_foreach(vd->calls, (GFunc) g_free, NULL);
g_slist_free(vd->calls);
g_slist_free_full(vd->calls, g_free);
vd->calls = calls;
@@ -1147,8 +1146,7 @@ static void at_voicecall_remove(struct ofono_voicecall *vc)
if (vd->vts_source)
g_source_remove(vd->vts_source);
g_slist_foreach(vd->calls, (GFunc) g_free, NULL);
g_slist_free(vd->calls);
g_slist_free_full(vd->calls, g_free);
ofono_voicecall_set_data(vc, NULL);

View File

@@ -0,0 +1,49 @@
/*
*
* oFono - Open Source Telephony
*
* Copyright (C) 2017 Vincent Cesson. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <glib.h>
#include <gatchat.h>
#define OFONO_API_SUBJECT_TO_CHANGE
#include <ofono/plugin.h>
#include <ofono/types.h>
#include "gemaltomodem.h"
static int gemaltomodem_init(void)
{
gemalto_location_reporting_init();
return 0;
}
static void gemaltomodem_exit(void)
{
gemalto_location_reporting_exit();
}
OFONO_PLUGIN_DEFINE(gemaltomodem, "Gemalto modem driver", VERSION,
OFONO_PLUGIN_PRIORITY_DEFAULT,
gemaltomodem_init, gemaltomodem_exit)

View File

@@ -2,7 +2,7 @@
*
* oFono - Open Source Telephony
*
* Copyright (C) 2008-2011 Intel Corporation. All rights reserved.
* Copyright (C) 2017 Vincent Cesson. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
@@ -19,11 +19,7 @@
*
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <drivers/atmodem/atutil.h>
int main(int argc, char **argv)
{
return 0;
}
extern void gemalto_location_reporting_init();
extern void gemalto_location_reporting_exit();

View File

@@ -0,0 +1,237 @@
/*
*
* oFono - Open Source Telephony
*
* Copyright (C) 2017 Vincent Cesson. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#define _GNU_SOURCE
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <glib.h>
#include <ofono/log.h>
#include <ofono/modem.h>
#include <ofono/location-reporting.h>
#include "gatchat.h"
#include "gatresult.h"
#include "gattty.h"
#include "gemaltomodem.h"
static const char *sgpsc_prefix[] = { "^SGPSC:", NULL };
struct gps_data {
GAtChat *chat;
};
static void gemalto_gps_disable_cb(gboolean ok, GAtResult *result,
gpointer user_data)
{
struct cb_data *cbd = user_data;
struct ofono_location_reporting *lr = cbd->user;
ofono_location_reporting_disable_cb_t cb = cbd->cb;
DBG("lr=%p, ok=%d", lr, ok);
if (!ok) {
struct ofono_error error;
decode_at_error(&error, g_at_result_final_response(result));
cb(&error, cbd->data);
return;
}
CALLBACK_WITH_SUCCESS(cb, cbd->data);
}
static void gemalto_location_reporting_disable(
struct ofono_location_reporting *lr,
ofono_location_reporting_disable_cb_t cb,
void *data)
{
struct gps_data *gd = ofono_location_reporting_get_data(lr);
struct cb_data *cbd = cb_data_new(cb, data);
DBG("lr=%p", lr);
cbd->user = lr;
if (g_at_chat_send(gd->chat, "AT^SGPSC=\"Engine\",0", sgpsc_prefix,
gemalto_gps_disable_cb, cbd, g_free) > 0)
return;
CALLBACK_WITH_FAILURE(cb, data);
g_free(cbd);
}
static int enable_data_stream(struct ofono_location_reporting *lr)
{
struct ofono_modem *modem;
const char *gps_dev;
GHashTable *options;
GIOChannel *channel;
int fd;
modem = ofono_location_reporting_get_modem(lr);
gps_dev = ofono_modem_get_string(modem, "GPS");
options = g_hash_table_new(g_str_hash, g_str_equal);
if (options == NULL)
return -1;
g_hash_table_insert(options, "Baud", "115200");
channel = g_at_tty_open(gps_dev, options);
g_hash_table_destroy(options);
if (channel == NULL)
return -1;
fd = g_io_channel_unix_get_fd(channel);
g_io_channel_set_close_on_unref(channel, FALSE);
g_io_channel_unref(channel);
return fd;
}
static void gemalto_sgpsc_cb(gboolean ok, GAtResult *result,
gpointer user_data)
{
struct cb_data *cbd = user_data;
ofono_location_reporting_enable_cb_t cb = cbd->cb;
struct ofono_location_reporting *lr = cbd->user;
struct ofono_error error;
int fd;
DBG("lr=%p ok=%d", lr, ok);
decode_at_error(&error, g_at_result_final_response(result));
if (!ok) {
cb(&error, -1, cbd->data);
return;
}
fd = enable_data_stream(lr);
if (fd < 0) {
CALLBACK_WITH_FAILURE(cb, -1, cbd->data);
return;
}
cb(&error, fd, cbd->data);
close(fd);
}
static void gemalto_location_reporting_enable(struct ofono_location_reporting *lr,
ofono_location_reporting_enable_cb_t cb,
void *data)
{
struct gps_data *gd = ofono_location_reporting_get_data(lr);
struct cb_data *cbd = cb_data_new(cb, data);
DBG("lr=%p", lr);
cbd->user = lr;
if (g_at_chat_send(gd->chat, "AT^SGPSC=\"Engine\",2", sgpsc_prefix,
gemalto_sgpsc_cb, cbd, NULL) > 0)
return;
CALLBACK_WITH_FAILURE(cb, -1, cbd->data);
g_free(cbd);
}
static void gemalto_location_reporting_support_cb(gboolean ok, GAtResult *result,
gpointer user_data)
{
struct ofono_location_reporting *lr = user_data;
if (!ok) {
ofono_location_reporting_remove(lr);
return;
}
ofono_location_reporting_register(lr);
}
static int gemalto_location_reporting_probe(struct ofono_location_reporting *lr,
unsigned int vendor, void *data)
{
GAtChat *chat = data;
struct gps_data *gd;
gd = g_try_new0(struct gps_data, 1);
if (gd == NULL)
return -ENOMEM;
gd->chat = g_at_chat_clone(chat);
ofono_location_reporting_set_data(lr, gd);
g_at_chat_send(gd->chat, "AT^SGPSC=?", sgpsc_prefix,
gemalto_location_reporting_support_cb,
lr, NULL);
return 0;
}
static void gemalto_location_reporting_remove(struct ofono_location_reporting *lr)
{
struct gps_data *gd = ofono_location_reporting_get_data(lr);
ofono_location_reporting_set_data(lr, NULL);
g_at_chat_unref(gd->chat);
g_free(gd);
}
static struct ofono_location_reporting_driver driver = {
.name = "gemaltomodem",
.type = OFONO_LOCATION_REPORTING_TYPE_NMEA,
.probe = gemalto_location_reporting_probe,
.remove = gemalto_location_reporting_remove,
.enable = gemalto_location_reporting_enable,
.disable = gemalto_location_reporting_disable,
};
void gemalto_location_reporting_init()
{
ofono_location_reporting_driver_register(&driver);
}
void gemalto_location_reporting_exit()
{
ofono_location_reporting_driver_unregister(&driver);
}

View File

@@ -45,6 +45,7 @@
static const char *binp_prefix[] = { "+BINP:", NULL };
static const char *bvra_prefix[] = { "+BVRA:", NULL };
static const char *none_prefix[] = { NULL };
struct hf_data {
GAtChat *chat;
@@ -197,7 +198,7 @@ static void hfp_cnum_query(struct ofono_handsfree *hf,
struct hf_data *hd = ofono_handsfree_get_data(hf);
struct cb_data *cbd = cb_data_new(cb, data);
if (g_at_chat_send(hd->chat, "AT+CNUM", NULL,
if (g_at_chat_send(hd->chat, "AT+CNUM", none_prefix,
cnum_query_cb, cbd, g_free) > 0)
return;
@@ -206,6 +207,27 @@ static void hfp_cnum_query(struct ofono_handsfree *hf,
CALLBACK_WITH_FAILURE(cb, -1, NULL, data);
}
static void bind_notify(GAtResult *result, gpointer user_data)
{
struct ofono_handsfree *hf = user_data;
int hf_indicator;
int active;
GAtResultIter iter;
g_at_result_iter_init(&iter, result);
if (!g_at_result_iter_next(&iter, "+BIND:"))
return;
if (!g_at_result_iter_next_number(&iter, &hf_indicator))
return;
if (!g_at_result_iter_next_number(&iter, &active))
return;
ofono_handsfree_hf_indicator_active_notify(hf, hf_indicator, active);
}
static gboolean hfp_handsfree_register(gpointer user_data)
{
struct ofono_handsfree *hf = user_data;
@@ -216,6 +238,7 @@ static gboolean hfp_handsfree_register(gpointer user_data)
g_at_chat_register(hd->chat, "+BSIR:", bsir_notify, FALSE, hf, NULL);
g_at_chat_register(hd->chat, "+BVRA:", bvra_notify, FALSE, hf, NULL);
g_at_chat_register(hd->chat, "+CIEV:", ciev_notify, FALSE, hf, NULL);
g_at_chat_register(hd->chat, "+BIND:", bind_notify, FALSE, hf, NULL);
if (hd->ag_features & HFP_AG_FEATURE_IN_BAND_RING_TONE)
ofono_handsfree_set_inband_ringing(hf, TRUE);
@@ -232,6 +255,7 @@ static int hfp_handsfree_probe(struct ofono_handsfree *hf,
{
struct hfp_slc_info *info = data;
struct hf_data *hd;
unsigned int i;
DBG("");
hd = g_new0(struct hf_data, 1);
@@ -245,6 +269,14 @@ static int hfp_handsfree_probe(struct ofono_handsfree *hf,
ofono_handsfree_battchg_notify(hf,
info->cind_val[HFP_INDICATOR_BATTCHG]);
ofono_handsfree_set_hf_indicators(hf, info->hf_indicators,
info->num_hf_indicators);
for (i = 0; i < info->num_hf_indicators; i++)
ofono_handsfree_hf_indicator_active_notify(hf,
info->hf_indicators[i],
info->hf_indicator_active_map & (1 << i));
hd->register_source = g_idle_add(hfp_handsfree_register, hf);
return 0;
@@ -351,8 +383,27 @@ static void hfp_disable_nrec(struct ofono_handsfree *hf,
struct cb_data *cbd = cb_data_new(cb, data);
const char *buf = "AT+NREC=0";
if (g_at_chat_send(hd->chat, buf, NULL, hf_generic_set_cb,
cbd, g_free) > 0)
if (g_at_chat_send(hd->chat, buf, none_prefix,
hf_generic_set_cb, cbd, g_free) > 0)
return;
g_free(cbd);
CALLBACK_WITH_FAILURE(cb, data);
}
static void hfp_hf_indicator(struct ofono_handsfree *hf,
unsigned short indicator, unsigned int value,
ofono_handsfree_cb_t cb, void *data)
{
struct hf_data *hd = ofono_handsfree_get_data(hf);
struct cb_data *cbd = cb_data_new(cb, data);
char buf[128];
snprintf(buf, sizeof(buf), "AT+BIEV=%u,%u", indicator, value);
if (g_at_chat_send(hd->chat, buf, none_prefix,
hf_generic_set_cb, cbd, g_free) > 0)
return;
g_free(cbd);
@@ -368,6 +419,7 @@ static struct ofono_handsfree_driver driver = {
.request_phone_number = hfp_request_phone_number,
.voice_recognition = hfp_voice_recognition,
.disable_nrec = hfp_disable_nrec,
.hf_indicator = hfp_hf_indicator,
};
void hfp_handsfree_init(void)

View File

@@ -46,6 +46,7 @@
static const char *cops_prefix[] = { "+COPS:", NULL };
static const char *cind_prefix[] = { "+CIND:", NULL };
static const char *none_prefix[] = { NULL };
struct netreg_data {
GAtChat *chat;
@@ -263,7 +264,7 @@ static void hfp_current_operator(struct ofono_netreg *netreg,
cbd->user = netreg;
ok = g_at_chat_send(nd->chat, "AT+COPS=3,0", NULL,
ok = g_at_chat_send(nd->chat, "AT+COPS=3,0", none_prefix,
NULL, cbd, NULL);
if (ok)

View File

@@ -41,10 +41,12 @@
#include "hfp.h"
#include "slc.h"
static const char *none_prefix[] = { NULL };
static const char *brsf_prefix[] = { "+BRSF:", NULL };
static const char *cind_prefix[] = { "+CIND:", NULL };
static const char *cmer_prefix[] = { "+CMER:", NULL };
static const char *chld_prefix[] = { "+CHLD:", NULL };
static const char *bind_prefix[] = { "+BIND:", NULL };
struct slc_establish_data {
gint ref_count;
@@ -76,6 +78,14 @@ void hfp_slc_info_init(struct hfp_slc_info *info, guint16 version)
info->hf_features |= HFP_HF_FEATURE_CODEC_NEGOTIATION;
if (version < HFP_VERSION_1_7)
goto done;
info->hf_features |= HFP_HF_FEATURE_HF_INDICATORS;
memset(info->hf_indicators, 0, sizeof(info->hf_indicators));
info->num_hf_indicators = 0;
info->hf_indicator_active_map = 0;
done:
memset(info->cind_val, 0, sizeof(info->cind_val));
memset(info->cind_pos, 0, sizeof(info->cind_pos));
@@ -103,10 +113,109 @@ static void slc_established(struct slc_establish_data *sed)
{
struct hfp_slc_info *info = sed->info;
g_at_chat_send(info->chat, "AT+CMEE=1", NULL, NULL, NULL, NULL);
g_at_chat_send(info->chat, "AT+CMEE=1", none_prefix,
NULL, NULL, NULL);
sed->connect_cb(sed->userdata);
}
static void bind_query_cb(gboolean ok, GAtResult *result, gpointer user_data)
{
struct slc_establish_data *sed = user_data;
struct hfp_slc_info *info = sed->info;
GAtResultIter iter;
int hf_indicator;
int enabled;
unsigned int i;
if (!ok)
goto error;
g_at_result_iter_init(&iter, result);
while (g_at_result_iter_next(&iter, "+BIND:")) {
if (!g_at_result_iter_next_number(&iter, &hf_indicator))
goto error;
if (!g_at_result_iter_next_number(&iter, &enabled))
goto error;
ofono_info("AG wants indicator %d %s",
hf_indicator, enabled ? "enabled" : "disabled");
for (i = 0; i < info->num_hf_indicators; i++) {
if (info->hf_indicators[i] != hf_indicator)
continue;
info->hf_indicator_active_map |= enabled << i;
}
ofono_info("Active map: %02x", info->hf_indicator_active_map);
}
slc_established(sed);
return;
error:
slc_failed(sed);
}
static void bind_support_cb(gboolean ok, GAtResult *result, gpointer user_data)
{
struct slc_establish_data *sed = user_data;
struct hfp_slc_info *info = sed->info;
GAtResultIter iter;
int hf_indicator;
if (!ok)
goto error;
g_at_result_iter_init(&iter, result);
if (!g_at_result_iter_next(&iter, "+BIND:"))
goto error;
if (!g_at_result_iter_open_list(&iter))
goto error;
while (g_at_result_iter_next_number(&iter, &hf_indicator)) {
if (info->num_hf_indicators >= 20)
goto error;
ofono_info("AG supports the following HF indicator: %d",
hf_indicator);
info->hf_indicators[info->num_hf_indicators] = hf_indicator;
info->num_hf_indicators += 1;
}
if (!g_at_result_iter_close_list(&iter))
goto error;
slc_establish_data_ref(sed);
g_at_chat_send(info->chat, "AT+BIND?", bind_prefix,
bind_query_cb, sed, slc_establish_data_unref);
return;
error:
slc_failed(sed);
}
static void bind_set_cb(gboolean ok, GAtResult *result, gpointer user_data)
{
struct slc_establish_data *sed = user_data;
struct hfp_slc_info *info = sed->info;
if (!ok) {
slc_failed(sed);
return;
}
slc_establish_data_ref(sed);
g_at_chat_send(info->chat, "AT+BIND=?", bind_prefix,
bind_support_cb, sed, slc_establish_data_unref);
}
static void chld_cb(gboolean ok, GAtResult *result, gpointer user_data)
{
struct slc_establish_data *sed = user_data;
@@ -148,7 +257,14 @@ static void chld_cb(gboolean ok, GAtResult *result, gpointer user_data)
info->ag_mpty_features = ag_mpty_feature;
slc_established(sed);
if ((info->ag_features & HFP_AG_FEATURE_HF_INDICATORS) &&
(info->hf_features & HFP_HF_FEATURE_HF_INDICATORS)) {
slc_establish_data_ref(sed);
g_at_chat_send(info->chat, "AT+BIND=1", none_prefix,
bind_set_cb, sed, slc_establish_data_unref);
} else
slc_established(sed);
return;
error:
@@ -319,8 +435,8 @@ static void brsf_cb(gboolean ok, GAtResult *result, gpointer user_data)
sprintf(str, "AT+BAC=%d", HFP_CODEC_CVSD);
slc_establish_data_ref(sed);
g_at_chat_send(info->chat, str, NULL, bac_cb, sed,
slc_establish_data_unref);
g_at_chat_send(info->chat, str, none_prefix, bac_cb,
sed, slc_establish_data_unref);
return;
}

View File

@@ -39,6 +39,9 @@ struct hfp_slc_info {
unsigned int hf_features;
unsigned char cind_pos[HFP_INDICATOR_LAST];
unsigned int cind_val[HFP_INDICATOR_LAST];
unsigned short hf_indicators[20];
unsigned char num_hf_indicators;
unsigned int hf_indicator_active_map;
};
void hfp_slc_info_init(struct hfp_slc_info *info, guint16 version);

View File

@@ -46,6 +46,7 @@
#define POLL_CLCC_DELAY 50
#define EXPECT_RELEASE_DELAY 50
#define CLIP_TIMEOUT 500
#define EXPECT_RING_DELAY 200
static const char *none_prefix[] = { NULL };
static const char *clcc_prefix[] = { "+CLCC:", NULL };
@@ -285,8 +286,7 @@ static void clcc_poll_cb(gboolean ok, GAtResult *result, gpointer user_data)
ofono_voicecall_mpty_hint(vc, mpty_ids);
g_slist_foreach(vd->calls, (GFunc) g_free, NULL);
g_slist_free(vd->calls);
g_slist_free_full(vd->calls, g_free);
vd->calls = calls;
@@ -294,7 +294,7 @@ static void clcc_poll_cb(gboolean ok, GAtResult *result, gpointer user_data)
* we won't get indicator update if any of them is released by CHLD=1x.
* So we have to poll it.
*/
if (num_active > 1 || num_held > 1)
if ((num_active > 1 || num_held > 1) && !vd->clcc_source)
vd->clcc_source = g_timeout_add(POLL_CLCC_INTERVAL, poll_clcc,
vc);
}
@@ -332,6 +332,10 @@ static void generic_cb(gboolean ok, GAtResult *result, gpointer user_data)
}
}
if (!ok && vd->calls)
g_at_chat_send(vd->chat, "AT+CLCC", clcc_prefix,
clcc_poll_cb, req->vc, NULL);
req->cb(&error, req->data);
}
@@ -499,6 +503,19 @@ static gboolean expect_release(gpointer user_data)
return FALSE;
}
static gboolean expect_ring(gpointer user_data)
{
struct ofono_voicecall *vc = user_data;
struct voicecall_data *vd = ofono_voicecall_get_data(vc);
g_at_chat_send(vd->chat, "AT+CLCC", clcc_prefix,
clcc_poll_cb, vc, NULL);
vd->clip_source = 0;
return FALSE;
}
static void release_all_active_cb(gboolean ok, GAtResult *result,
gpointer user_data)
{
@@ -640,8 +657,10 @@ static void hfp_send_dtmf(struct ofono_voicecall *vc, const char *dtmf,
{
struct voicecall_data *vd = ofono_voicecall_get_data(vc);
struct change_state_req *req = g_try_new0(struct change_state_req, 1);
int len = strlen(dtmf);
char *buf;
int s;
int i;
if (req == NULL)
goto error;
@@ -651,12 +670,15 @@ static void hfp_send_dtmf(struct ofono_voicecall *vc, const char *dtmf,
req->data = data;
req->affected_types = 0;
/* strlen("AT+VTS=) = 7 + NULL */
buf = g_try_new(char, strlen(dtmf) + 8);
/* strlen("AT") + (n-1) * strlen("+VTS=T;") + strlen(+VTS=T) + null */
buf = g_try_new(char, len * 7 + 2);
if (buf == NULL)
goto error;
sprintf(buf, "AT+VTS=%s", dtmf);
s = sprintf(buf, "AT+VTS=%c", dtmf[0]);
for (i = 1; i < len; i++)
s += sprintf(buf + s, ";+VTS=%c", dtmf[i]);
s = g_at_chat_send(vd->chat, buf, none_prefix,
generic_cb, req, g_free);
@@ -686,12 +708,31 @@ static void ccwa_notify(GAtResult *result, gpointer user_data)
int num_type, validity;
struct ofono_call *call;
/* Waiting call notification makes no sense, when there are
* no calls at all. This can happen when a phone already has
* waiting and active calls and is being connected over HFP
* but it first sends +CCWA before we manage to synchronize
* calls with AT+CLCC.
*/
if (!vd->calls)
return;
/* CCWA can repeat, ignore if we already have an waiting call */
if (g_slist_find_custom(vd->calls,
GINT_TO_POINTER(CALL_STATUS_WAITING),
at_util_call_compare_by_status))
return;
/* some phones may send extra CCWA after active call is ended
* this would trigger creation of second call in state 'WAITING'
* as our previous WAITING call has been promoted to INCOMING
*/
if (g_slist_find_custom(vd->calls,
GINT_TO_POINTER(CALL_STATUS_INCOMING),
at_util_call_compare_by_status))
return;
g_at_result_iter_init(&iter, result);
if (!g_at_result_iter_next(&iter, "+CCWA:"))
@@ -752,6 +793,11 @@ static void ring_notify(GAtResult *result, gpointer user_data)
struct ofono_call *call;
GSList *waiting;
if (vd->clip_source) {
g_source_remove(vd->clip_source);
vd->clip_source = 0;
}
/* RING can repeat, ignore if we already have an incoming call */
if (g_slist_find_custom(vd->calls,
GINT_TO_POINTER(CALL_STATUS_INCOMING),
@@ -976,7 +1022,15 @@ static void ciev_callsetup_notify(struct ofono_voicecall *vc,
break;
case 1:
/* Handled in RING/CCWA */
/*
* Handled in RING/CCWA most of the time, however sometimes
* the call is answered before the RING unsolicited
* notification has a chance to be generated on the device.
* In this case, we use a failsafe CLCC poll in expect_ring
* callback.
* */
vd->clip_source = g_timeout_add(EXPECT_RING_DELAY,
expect_ring, vc);
break;
case 2:
@@ -1064,6 +1118,17 @@ static void ciev_callheld_notify(struct ofono_voicecall *vc,
*/
vd->clcc_source = g_timeout_add(POLL_CLCC_DELAY,
poll_clcc, vc);
} else {
if (vd->clcc_source)
g_source_remove(vd->clcc_source);
/*
* We got a notification that there is a held call
* and no active call but we already are in such state.
* Let's schedule a poll to see what happened.
*/
vd->clcc_source = g_timeout_add(POLL_CLCC_DELAY,
poll_clcc, vc);
}
}
@@ -1102,6 +1167,10 @@ static void hfp_clcc_cb(gboolean ok, GAtResult *result, gpointer user_data)
struct ofono_voicecall *vc = user_data;
struct voicecall_data *vd = ofono_voicecall_get_data(vc);
unsigned int mpty_ids;
GSList *n;
struct ofono_call *nc;
unsigned int num_active = 0;
unsigned int num_held = 0;
if (!ok)
return;
@@ -1110,6 +1179,22 @@ static void hfp_clcc_cb(gboolean ok, GAtResult *result, gpointer user_data)
g_slist_foreach(vd->calls, voicecall_notify, vc);
ofono_voicecall_mpty_hint(vc, mpty_ids);
n = vd->calls;
while (n) {
nc = n->data;
if (nc->status == CALL_STATUS_ACTIVE)
num_active++;
else if (nc->status == CALL_STATUS_HELD)
num_held++;
n = n->next;
}
if ((num_active > 1 || num_held > 1) && !vd->clcc_source)
vd->clcc_source = g_timeout_add(POLL_CLCC_INTERVAL, poll_clcc, vc);
}
static void hfp_voicecall_initialized(gboolean ok, GAtResult *result,
@@ -1151,8 +1236,8 @@ static int hfp_voicecall_probe(struct ofono_voicecall *vc, unsigned int vendor,
ofono_voicecall_set_data(vc, vd);
g_at_chat_send(vd->chat, "AT+CLIP=1", NULL, NULL, NULL, NULL);
g_at_chat_send(vd->chat, "AT+CCWA=1", NULL,
g_at_chat_send(vd->chat, "AT+CLIP=1", none_prefix, NULL, NULL, NULL);
g_at_chat_send(vd->chat, "AT+CCWA=1", none_prefix,
hfp_voicecall_initialized, vc, NULL);
return 0;
}
@@ -1170,8 +1255,7 @@ static void hfp_voicecall_remove(struct ofono_voicecall *vc)
if (vd->expect_release_source)
g_source_remove(vd->expect_release_source);
g_slist_foreach(vd->calls, (GFunc) g_free, NULL);
g_slist_free(vd->calls);
g_slist_free_full(vd->calls, g_free);
ofono_voicecall_set_data(vc, NULL);

View File

@@ -80,7 +80,7 @@ static gboolean get_next_addr(GAtResultIter *iter, char **addr)
if (g_at_result_iter_next_unquoted_string(iter, &str) == FALSE)
return FALSE;
val = strtol(str, NULL, 16);
val = strtoul(str, NULL, 16);
if (addr)
*addr = g_strdup_printf("%u.%u.%u.%u",

View File

@@ -1009,8 +1009,7 @@ static void ifx_voicecall_remove(struct ofono_voicecall *vc)
{
struct voicecall_data *vd = ofono_voicecall_get_data(vc);
g_slist_foreach(vd->calls, (GFunc) g_free, NULL);
g_slist_free(vd->calls);
g_slist_free_full(vd->calls, g_free);
g_strfreev(vd->en_list);

View File

@@ -0,0 +1,77 @@
/*
*
* RIL constants for infineon modem
*
* Copyright (C) 2014 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#ifndef INFINEON_CONSTANTS_H
#define INFINEON_CONSTANTS_H
/* Messages encapsulated in RIL_REQUEST_OEM_HOOK_RAW requests */
#define INF_RIL_REQUEST_OEM_QUERY_SELECT_BAND 1
#define INF_RIL_REQUEST_OEM_SET_SELECT_BAND 2
#define INF_RIL_REQUEST_OEM_SET_CIRCUIT_SWITCHING_PAGING 3
#define INF_RIL_REQUEST_OEM_GET_LAST_FAILURE_REPORT_FOR_CS_REGISTRATION 4
#define INF_RIL_REQUEST_OEM_GET_SELECT_BEARER_SERVICE_TYPE 5
#define INF_RIL_REQUEST_OEM_GET_XPROGRESS_STATUS 6
#define INF_RIL_REQUEST_OEM_SET_SS_NOTIFY 7
#define INF_RIL_REQUEST_OEM_GET_SS_NOTIFY 8
#define INF_RIL_REQUEST_OEM_SET_AUTHENTICATION_TYPE 9
#define INF_RIL_REQUEST_OEM_SWITCH_OFF_MS 10
#define INF_RIL_REQUEST_OEM_SET_AUTO_TIMEZONE_UPDATE 11
#define INF_RIL_REQUEST_OEM_SET_TIMEZONE_RESPORTING 12
#define INF_RIL_REQUEST_OEM_SET_DISPLAY_SIM_AND_PB_STATUS 13
#define INF_RIL_REQUEST_OEM_GET_REMAIN_SIM_PIN_ATTEMPTS 14
#define INF_RIL_REQUEST_OEM_SET_AUTO_REDIAL 15
#define INF_RIL_REQUEST_OEM_QUERY_CALL_STATUS_REPORTING 16
#define INF_RIL_REQUEST_OEM_SET_AUTO_ANSWER 17
#define INF_RIL_REQUEST_OEM_SET_LINE 18
#define INF_RIL_REQUEST_OEM_PDP_ACTIVATE_OR_DEACTIVATE 19
#define INF_RIL_REQUEST_OEM_QUERY_GPRS_MS_CLASS 20
#define INF_RIL_REQUEST_OEM_SET_TRACE_AND_AT_INTERFACES 21
#define INF_RIL_REQUEST_OEM_QUERY_TRACE_AND_AT_INTERFACES_CONFIGURE 22
#define INF_RIL_REQUEST_OEM_SWITCH_TRACE_ON_OR_OFF 23
#define INF_RIL_REQUEST_OEM_READ_EXCEPTION_LOG 24
#define INF_RIL_REQUEST_OEM_GET_PHONE_ACTIVITY_STATUS 25
#define INF_RIL_REQUEST_OEM_INITIATE_RESEND_SMS_IF_GPRS_FAILS 26
#define INF_RIL_REQUEST_OEM_GET_DEVICE_NUMBER 27
#define INF_RIL_REQUEST_OEM_ENABLE_STK 28
#define INF_RIL_REQUEST_OEM_GET_SUBSCRIBER_NUMBER 29
#define INF_RIL_REQUEST_OEM_SELECT_PHONE_BOOK 30
#define INF_RIL_REQUEST_OEM_READ_PHONE_BOOK 31
#define INF_RIL_REQUEST_OEM_INSERT_RECORD_TO_PHONE_BOOK 32
#define INF_RIL_REQUEST_OEM_DELECT_RECORD_IN_PHONE_BOOK 33
#define INF_RIL_REQUEST_OEM_GET_RECORD_FIELDS_MAX_LEN 34
#define INF_RIL_REQUEST_OEM_SET_SERIAL_PORT 35
#define INF_RIL_REQUEST_OEM_SET_DATA_PREFERED 36
#define INF_RIL_REQUEST_OEM_SET_MODEM_ROUTING 37
#define INF_RIL_REQUEST_OEM_CLEAR_MISS_NUMBER 38
#define INF_RIL_REQUEST_OEM_ATH 39
#define INF_RIL_REQUEST_OEM_NOSIG_MODE_TEST 40
#define INF_RIL_REQUEST_OEM_SELECT_3G_BAND 41
#define INF_RIL_REQUEST_OEM_QUERY_3G_BAND 42
#define INF_RIL_REQUEST_OEM_HW_RESET_MODEM 43
#define INF_RIL_REQUEST_OEM_QUERY_DIRECT 44
#define INF_RIL_REQUEST_OEM_USER_PLMN_QUERY 45
#define INF_RIL_REQUEST_OEM_USER_PLMN_SET 46
#define INF_RIL_REQUEST_OEM_USER_PLMN_DELTE 47
#define INF_RIL_REQUEST_OEM_SET_USB_LOG 48
#define INF_RIL_REQUEST_OEM_UPDATE_CSQ 49
#define INF_RIL_REQUEST_OEM_DUMP_CELL_ENV 50
#endif /* INFINEON_CONSTANTS_H */

View File

@@ -134,7 +134,9 @@ static void routing_resp_cb(const GIsiMessage *msg, void *data)
struct cbs_data *cd = ofono_cbs_get_data(cbs);
if (!check_resp(msg, SMS_GSM_CB_ROUTING_RESP)) {
ofono_cbs_remove(cbs);
/* on shutdown, cbs is already being removed */
if (g_isi_msg_error(msg) != -ESHUTDOWN)
ofono_cbs_remove(cbs);
return;
}

View File

@@ -652,7 +652,7 @@ static void sec_code_state_resp_cb(const GIsiMessage *msg, void *opaque)
static void isi_query_locked(struct ofono_sim *sim,
enum ofono_sim_password_type passwd_type,
ofono_sim_locked_cb_t cb, void *data)
ofono_query_facility_lock_cb_t cb, void *data)
{
struct sim_data *sd = ofono_sim_get_data(sim);
struct isi_cb_data *cbd = isi_cb_data_new(sim, cb, data);
@@ -963,7 +963,7 @@ static struct ofono_sim_driver driver = {
.reset_passwd = isi_reset_passwd,
.lock = isi_lock,
.change_passwd = isi_change_passwd,
.query_locked = isi_query_locked,
.query_facility_lock = isi_query_locked,
};
void isi_sim_init(void)

View File

@@ -1032,14 +1032,6 @@ static void uicc_lock(struct ofono_sim *sim, enum ofono_sim_password_type type,
CALLBACK_WITH_FAILURE(cb, data);
}
static void uicc_query_locked(struct ofono_sim *sim,
enum ofono_sim_password_type type,
ofono_sim_locked_cb_t cb, void *data)
{
DBG("Not implemented");
CALLBACK_WITH_FAILURE(cb, -1, data);
}
static gboolean decode_fcp_pin_status(const GIsiSubBlockIter *iter, uint8_t read,
uint8_t *pin1, uint8_t *pin2)
{
@@ -1677,7 +1669,6 @@ static struct ofono_sim_driver driver = {
.reset_passwd = uicc_reset_passwd,
.change_passwd = uicc_change_passwd,
.lock = uicc_lock,
.query_locked = uicc_query_locked,
};
void isi_uicc_init(void)

View File

@@ -1715,7 +1715,7 @@ static void isi_release_specific(struct ofono_voicecall *ovc, int id,
if ((status->mode_info & CALL_MODE_ORIGINATOR))
cause = CALL_CAUSE_BUSY_USER_REQUEST;
break;
break;
}
isi_call_release_req(ovc, id, CALL_CAUSE_TYPE_CLIENT, cause, cb, data);

View File

@@ -23,6 +23,8 @@
#include <config.h>
#endif
#include <string.h>
#include <ofono/log.h>
#include <ofono/modem.h>
#include <ofono/devinfo.h>
@@ -125,7 +127,8 @@ static void get_ids_cb(struct qmi_result *result, void *user_data)
}
str = qmi_result_get_string(result, QMI_DMS_RESULT_ESN);
if (!str) {
/* Telit qmi modems return a "0" string when ESN is not available. */
if (!str || strcmp(str, "0") == 0) {
str = qmi_result_get_string(result, QMI_DMS_RESULT_IMEI);
if (!str) {
CALLBACK_WITH_FAILURE(cb, NULL, cbd->data);

View File

@@ -24,18 +24,22 @@
#endif
#include <string.h>
#include <arpa/inet.h>
#include <ofono/log.h>
#include <ofono/modem.h>
#include <ofono/gprs-context.h>
#include "qmi.h"
#include "wda.h"
#include "wds.h"
#include "qmimodem.h"
struct gprs_context_data {
struct qmi_service *wds;
struct qmi_service *wda;
struct qmi_device *dev;
unsigned int active_context;
uint32_t pkt_handle;
};
@@ -61,8 +65,12 @@ static void pkt_status_notify(struct qmi_result *result, void *user_data)
switch (status->status) {
case QMI_WDS_CONN_STATUS_DISCONNECTED:
ofono_gprs_context_deactivated(gc, data->active_context);
data->active_context = 0;
if (data->pkt_handle) {
/* The context has been disconnected by the network */
ofono_gprs_context_deactivated(gc, data->active_context);
data->pkt_handle = 0;
data->active_context = 0;
}
break;
}
}
@@ -75,18 +83,68 @@ static void get_settings_cb(struct qmi_result *result, void *user_data)
struct ofono_modem *modem;
const char *interface;
uint8_t pdp_type, ip_family;
uint32_t ip_addr;
struct in_addr addr;
char* straddr;
char* apn;
const char *dns[3] = { NULL, NULL, NULL };
DBG("");
if (qmi_result_set_error(result, NULL))
goto done;
apn = qmi_result_get_string(result, QMI_WDS_RESULT_APN);
if (apn) {
DBG("APN: %s", apn);
g_free(apn);
}
if (qmi_result_get_uint8(result, QMI_WDS_RESULT_PDP_TYPE, &pdp_type))
DBG("PDP type %d", pdp_type);
if (qmi_result_get_uint8(result, QMI_WDS_RESULT_IP_FAMILY, &ip_family))
DBG("IP family %d", ip_family);
if (qmi_result_get_uint32(result,QMI_WDS_RESULT_IP_ADDRESS, &ip_addr)) {
addr.s_addr = htonl(ip_addr);
straddr = inet_ntoa(addr);
DBG("IP addr: %s", straddr);
ofono_gprs_context_set_ipv4_address(gc, straddr, 1);
}
if (qmi_result_get_uint32(result,QMI_WDS_RESULT_GATEWAY, &ip_addr)) {
addr.s_addr = htonl(ip_addr);
straddr = inet_ntoa(addr);
DBG("Gateway: %s", straddr);
ofono_gprs_context_set_ipv4_gateway(gc, straddr);
}
if (qmi_result_get_uint32(result,
QMI_WDS_RESULT_GATEWAY_NETMASK, &ip_addr)) {
addr.s_addr = htonl(ip_addr);
straddr = inet_ntoa(addr);
DBG("Gateway netmask: %s", straddr);
ofono_gprs_context_set_ipv4_netmask(gc, straddr);
}
if (qmi_result_get_uint32(result,
QMI_WDS_RESULT_PRIMARY_DNS, &ip_addr)) {
addr.s_addr = htonl(ip_addr);
dns[0] = inet_ntoa(addr);
DBG("Primary DNS: %s", dns[0]);
}
if (qmi_result_get_uint32(result,
QMI_WDS_RESULT_SECONDARY_DNS, &ip_addr)) {
addr.s_addr = htonl(ip_addr);
dns[1] = inet_ntoa(addr);
DBG("Secondary DNS: %s", dns[1]);
}
if (dns[0])
ofono_gprs_context_set_ipv4_dns_servers(gc, dns);
done:
modem = ofono_gprs_context_get_modem(gc);
interface = ofono_modem_get_string(modem, "NetworkInterface");
@@ -94,8 +152,6 @@ done:
ofono_gprs_context_set_interface(gc, interface);
CALLBACK_WITH_SUCCESS(cb, cbd->data);
g_free(cbd);
}
static void start_net_cb(struct qmi_result *result, void *user_data)
@@ -120,8 +176,12 @@ static void start_net_cb(struct qmi_result *result, void *user_data)
data->pkt_handle = handle;
/* Duplicate cbd, the old one will be freed when this method returns */
cbd = cb_data_new(cb, cbd->data);
cbd->user = gc;
if (qmi_service_send(data->wds, QMI_WDS_GET_SETTINGS, NULL,
get_settings_cb, cbd, NULL) > 0)
get_settings_cb, cbd, g_free) > 0)
return;
modem = ofono_gprs_context_get_modem(gc);
@@ -131,12 +191,39 @@ static void start_net_cb(struct qmi_result *result, void *user_data)
CALLBACK_WITH_SUCCESS(cb, cbd->data);
g_free(cbd);
return;
error:
data->active_context = 0;
CALLBACK_WITH_FAILURE(cb, cbd->data);
}
/*
* This function gets called for "automatic" contexts, those which are
* not activated via activate_primary. For these, we will still need
* to call start_net in order to get the packet handle for the context.
* The process for automatic contexts is essentially identical to that
* for others.
*/
static void qmi_gprs_read_settings(struct ofono_gprs_context* gc,
unsigned int cid,
ofono_gprs_context_cb_t cb,
void *user_data)
{
struct gprs_context_data *data = ofono_gprs_context_get_data(gc);
struct cb_data *cbd = cb_data_new(cb, user_data);
DBG("cid %u", cid);
data->active_context = cid;
cbd->user = gc;
if (qmi_service_send(data->wds, QMI_WDS_START_NET, NULL,
start_net_cb, cbd, g_free) > 0)
return;
data->active_context = 0;
CALLBACK_WITH_FAILURE(cb, cbd->data);
@@ -151,6 +238,7 @@ static void qmi_activate_primary(struct ofono_gprs_context *gc,
struct cb_data *cbd = cb_data_new(cb, user_data);
struct qmi_param *param;
uint8_t ip_family;
uint8_t auth;
DBG("cid %u", ctx->cid);
@@ -178,8 +266,31 @@ static void qmi_activate_primary(struct ofono_gprs_context *gc,
qmi_param_append_uint8(param, QMI_WDS_PARAM_IP_FAMILY, ip_family);
switch (ctx->auth_method) {
case OFONO_GPRS_AUTH_METHOD_CHAP:
auth = QMI_WDS_AUTHENTICATION_CHAP;
break;
case OFONO_GPRS_AUTH_METHOD_PAP:
auth = QMI_WDS_AUTHENTICATION_PAP;
break;
default:
auth = QMI_WDS_AUTHENTICATION_NONE;
break;
}
qmi_param_append_uint8(param, QMI_WDS_PARAM_AUTHENTICATION_PREFERENCE,
auth);
if (ctx->username[0] != '\0')
qmi_param_append(param, QMI_WDS_PARAM_USERNAME,
strlen(ctx->username), ctx->username);
if (ctx->password[0] != '\0')
qmi_param_append(param, QMI_WDS_PARAM_PASSWORD,
strlen(ctx->password), ctx->password);
if (qmi_service_send(data->wds, QMI_WDS_START_NET, param,
start_net_cb, cbd, NULL) > 0)
start_net_cb, cbd, g_free) > 0)
return;
qmi_param_free(param);
@@ -202,17 +313,19 @@ static void stop_net_cb(struct qmi_result *result, void *user_data)
DBG("");
if (qmi_result_set_error(result, NULL)) {
CALLBACK_WITH_FAILURE(cb, cbd->data);
if (cb)
CALLBACK_WITH_FAILURE(cb, cbd->data);
return;
}
data->active_context = 0;
data->pkt_handle = 0;
CALLBACK_WITH_SUCCESS(cb, cbd->data);
if (cb)
CALLBACK_WITH_SUCCESS(cb, cbd->data);
else
ofono_gprs_context_deactivated(gc, data->active_context);
g_free(cbd);
data->active_context = 0;
}
static void qmi_deactivate_primary(struct ofono_gprs_context *gc,
@@ -233,17 +346,26 @@ static void qmi_deactivate_primary(struct ofono_gprs_context *gc,
goto error;
if (qmi_service_send(data->wds, QMI_WDS_STOP_NET, param,
stop_net_cb, cbd, NULL) > 0)
stop_net_cb, cbd, g_free) > 0)
return;
qmi_param_free(param);
error:
CALLBACK_WITH_FAILURE(cb, cbd->data);
if (cb)
CALLBACK_WITH_FAILURE(cb, user_data);
g_free(cbd);
}
static void qmi_gprs_context_detach_shutdown(struct ofono_gprs_context *gc,
unsigned int cid)
{
DBG("");
qmi_deactivate_primary(gc, cid, NULL, NULL);
}
static void create_wds_cb(struct qmi_service *service, void *user_data)
{
struct ofono_gprs_context *gc = user_data;
@@ -263,6 +385,69 @@ static void create_wds_cb(struct qmi_service *service, void *user_data)
pkt_status_notify, gc, NULL);
}
static void get_data_format_cb(struct qmi_result *result, void *user_data)
{
struct ofono_gprs_context *gc = user_data;
struct gprs_context_data *data = ofono_gprs_context_get_data(gc);
uint32_t llproto;
enum qmi_device_expected_data_format expected_llproto;
DBG("");
if (qmi_result_set_error(result, NULL))
goto done;
if (!qmi_result_get_uint32(result, QMI_WDA_LL_PROTOCOL, &llproto))
goto done;
expected_llproto = qmi_device_get_expected_data_format(data->dev);
if ((llproto == QMI_WDA_DATA_LINK_PROTOCOL_802_3) &&
(expected_llproto ==
QMI_DEVICE_EXPECTED_DATA_FORMAT_RAW_IP)) {
if (!qmi_device_set_expected_data_format(data->dev,
QMI_DEVICE_EXPECTED_DATA_FORMAT_802_3))
DBG("Fail to set expected data to 802.3");
else
DBG("expected data set to 802.3");
} else if ((llproto == QMI_WDA_DATA_LINK_PROTOCOL_RAW_IP) &&
(expected_llproto ==
QMI_DEVICE_EXPECTED_DATA_FORMAT_802_3)) {
if (!qmi_device_set_expected_data_format(data->dev,
QMI_DEVICE_EXPECTED_DATA_FORMAT_RAW_IP))
DBG("Fail to set expected data to raw-ip");
else
DBG("expected data set to raw-ip");
}
done:
qmi_service_create_shared(data->dev, QMI_SERVICE_WDS, create_wds_cb, gc,
NULL);
}
static void create_wda_cb(struct qmi_service *service, void *user_data)
{
struct ofono_gprs_context *gc = user_data;
struct gprs_context_data *data = ofono_gprs_context_get_data(gc);
DBG("");
if (!service) {
DBG("Failed to request WDA service, continue initialization");
goto error;
}
data->wda = qmi_service_ref(service);
if (qmi_service_send(data->wda, QMI_WDA_GET_DATA_FORMAT, NULL,
get_data_format_cb, gc, NULL) > 0)
return;
error:
qmi_service_create_shared(data->dev, QMI_SERVICE_WDS, create_wds_cb, gc,
NULL);
}
static int qmi_gprs_context_probe(struct ofono_gprs_context *gc,
unsigned int vendor, void *user_data)
{
@@ -274,8 +459,9 @@ static int qmi_gprs_context_probe(struct ofono_gprs_context *gc,
data = g_new0(struct gprs_context_data, 1);
ofono_gprs_context_set_data(gc, data);
data->dev = device;
qmi_service_create(device, QMI_SERVICE_WDS, create_wds_cb, gc, NULL);
qmi_service_create(device, QMI_SERVICE_WDA, create_wda_cb, gc, NULL);
return 0;
}
@@ -288,9 +474,15 @@ static void qmi_gprs_context_remove(struct ofono_gprs_context *gc)
ofono_gprs_context_set_data(gc, NULL);
qmi_service_unregister_all(data->wds);
if (data->wds) {
qmi_service_unregister_all(data->wds);
qmi_service_unref(data->wds);
}
qmi_service_unref(data->wds);
if (data->wda) {
qmi_service_unregister_all(data->wda);
qmi_service_unref(data->wda);
}
g_free(data);
}
@@ -301,6 +493,8 @@ static struct ofono_gprs_context_driver driver = {
.remove = qmi_gprs_context_remove,
.activate_primary = qmi_activate_primary,
.deactivate_primary = qmi_deactivate_primary,
.read_settings = qmi_gprs_read_settings,
.detach_shutdown = qmi_gprs_context_detach_shutdown,
};
void qmi_gprs_context_init(void)

View File

@@ -30,16 +30,18 @@
#include "qmi.h"
#include "nas.h"
#include "src/common.h"
#include "qmimodem.h"
struct gprs_data {
struct qmi_service *nas;
};
static bool extract_ss_info(struct qmi_result *result, int *status)
static bool extract_ss_info(struct qmi_result *result, int *status, int *tech)
{
const struct qmi_nas_serving_system *ss;
uint16_t len;
int i;
DBG("");
@@ -47,14 +49,46 @@ static bool extract_ss_info(struct qmi_result *result, int *status)
if (!ss)
return false;
if (ss->ps_state == QMI_NAS_ATTACH_STATUS_ATTACHED)
*status = 0x01;
if (ss->ps_state == QMI_NAS_ATTACH_STATE_ATTACHED)
*status = NETWORK_REGISTRATION_STATUS_REGISTERED;
else
*status = 0x00;
*status = NETWORK_REGISTRATION_STATUS_NOT_REGISTERED;
*tech = -1;
for (i = 0; i < ss->radio_if_count; i++) {
DBG("radio in use %d", ss->radio_if[i]);
*tech = qmi_nas_rat_to_tech(ss->radio_if[i]);
}
return true;
}
static int handle_ss_info(struct qmi_result *result, struct ofono_gprs *gprs)
{
int status;
int tech;
DBG("");
if (!extract_ss_info(result, &status, &tech))
return -1;
if (status == NETWORK_REGISTRATION_STATUS_REGISTERED)
if (tech == ACCESS_TECHNOLOGY_EUTRAN) {
/* On LTE we are effectively always attached; and
* the default bearer is established as soon as the
* network is joined.
*/
/* FIXME: query default profile number and APN
* instead of assuming profile 1 and ""
*/
ofono_gprs_cid_activated(gprs, 1 , "automatic");
}
return status;
}
static void ss_info_notify(struct qmi_result *result, void *user_data)
{
struct ofono_gprs *gprs = user_data;
@@ -62,10 +96,10 @@ static void ss_info_notify(struct qmi_result *result, void *user_data)
DBG("");
if (!extract_ss_info(result, &status))
return;
status = handle_ss_info(result, gprs);
ofono_gprs_status_notify(gprs, status);
if (status >= 0)
ofono_gprs_status_notify(gprs, status);
}
static void attach_detach_cb(struct qmi_result *result, void *user_data)
@@ -124,22 +158,26 @@ error:
static void get_ss_info_cb(struct qmi_result *result, void *user_data)
{
struct cb_data *cbd = user_data;
struct ofono_gprs *gprs = cbd->user;
ofono_gprs_status_cb_t cb = cbd->cb;
int status;
DBG("");
if (qmi_result_set_error(result, NULL)) {
CALLBACK_WITH_FAILURE(cb, -1, cbd->data);
return;
}
if (qmi_result_set_error(result, NULL))
goto error;
if (!extract_ss_info(result, &status)) {
CALLBACK_WITH_FAILURE(cb, -1, cbd->data);
return;
}
status = handle_ss_info(result, gprs);
if (status < 0)
goto error;
CALLBACK_WITH_SUCCESS(cb, status, cbd->data);
return;
error:
CALLBACK_WITH_FAILURE(cb, -1, cbd->data);
}
static void qmi_attached_status(struct ofono_gprs *gprs,
@@ -150,6 +188,7 @@ static void qmi_attached_status(struct ofono_gprs *gprs,
DBG("");
cbd->user = gprs;
if (qmi_service_send(data->nas, QMI_NAS_GET_SS_INFO, NULL,
get_ss_info_cb, cbd, g_free) > 0)
return;
@@ -174,6 +213,13 @@ static void create_nas_cb(struct qmi_service *service, void *user_data)
data->nas = qmi_service_ref(service);
/*
* First get the SS info - the modem may already be connected,
* and the state-change notification may never arrive
*/
qmi_service_send(data->nas, QMI_NAS_GET_SS_INFO, NULL,
ss_info_notify, gprs, NULL);
qmi_service_register(data->nas, QMI_NAS_SS_INFO_IND,
ss_info_notify, gprs, NULL);
@@ -194,7 +240,8 @@ static int qmi_gprs_probe(struct ofono_gprs *gprs,
ofono_gprs_set_data(gprs, data);
qmi_service_create(device, QMI_SERVICE_NAS, create_nas_cb, gprs, NULL);
qmi_service_create_shared(device, QMI_SERVICE_NAS,
create_nas_cb, gprs, NULL);
return 0;
}

View File

@@ -0,0 +1,38 @@
/*
*
* oFono - Open Source Telephony
*
* Copyright (C) 2017 Jonas Bonn. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#include "nas.h"
#include "src/common.h"
int qmi_nas_rat_to_tech(uint8_t rat)
{
switch (rat) {
case QMI_NAS_NETWORK_RAT_GSM:
return ACCESS_TECHNOLOGY_GSM;
case QMI_NAS_NETWORK_RAT_UMTS:
return ACCESS_TECHNOLOGY_UTRAN;
case QMI_NAS_NETWORK_RAT_LTE:
return ACCESS_TECHNOLOGY_EUTRAN;
}
return -1;
}

View File

@@ -19,6 +19,8 @@
*
*/
#include <stdint.h>
#define QMI_NAS_RESET 0 /* Reset NAS service state variables */
#define QMI_NAS_ABORT 1 /* Abort previously issued NAS command */
#define QMI_NAS_EVENT 2 /* Connection state report indication */
@@ -63,7 +65,7 @@ struct qmi_nas_rf_info {
} __attribute__((__packed__));
/* Get the signal strength */
#define QMI_NAS_RESULT_SIGNAL_STRENGTH 0x10
#define QMI_NAS_RESULT_SIGNAL_STRENGTH 0x01
/* Scan for visible network */
#define QMI_NAS_PARAM_NETWORK_MASK 0x10 /* uint8 bitmask */
@@ -140,9 +142,17 @@ struct qmi_nas_current_plmn {
#define QMI_NAS_RESULT_LOCATION_AREA_CODE 0x1d /* uint16 */
#define QMI_NAS_RESULT_CELL_ID 0x1e /* uint32 */
#define QMI_NAS_ATTACH_STATUS_INVALID 0x00
#define QMI_NAS_ATTACH_STATUS_ATTACHED 0x01
#define QMI_NAS_ATTACH_STATUS_DETACHED 0x02
/* qmi_nas_serving_system.status */
#define QMI_NAS_REGISTRATION_STATE_NOT_REGISTERED 0x00
#define QMI_NAS_REGISTRATION_STATE_REGISTERED 0x01
#define QMI_NAS_REGISTRATION_STATE_SEARCHING 0x02
#define QMI_NAS_REGISTRATION_STATE_DENIED 0x03
#define QMI_NAS_REGISTRATION_STATE_UNKNOWN 0x04
/* cs_state/ps_state */
#define QMI_NAS_ATTACH_STATE_INVALID 0x00
#define QMI_NAS_ATTACH_STATE_ATTACHED 0x01
#define QMI_NAS_ATTACH_STATE_DETACHED 0x02
/* Get info about home network */
#define QMI_NAS_RESULT_HOME_NETWORK 0x01
@@ -152,3 +162,5 @@ struct qmi_nas_home_network {
uint8_t desc_len;
char desc[0];
} __attribute__((__packed__));
int qmi_nas_rat_to_tech(uint8_t rat);

View File

@@ -43,20 +43,6 @@ struct netreg_data {
uint8_t current_rat;
};
static int rat_to_tech(uint8_t rat)
{
switch (rat) {
case QMI_NAS_NETWORK_RAT_GSM:
return ACCESS_TECHNOLOGY_GSM;
case QMI_NAS_NETWORK_RAT_UMTS:
return ACCESS_TECHNOLOGY_UTRAN;
case QMI_NAS_NETWORK_RAT_LTE:
return ACCESS_TECHNOLOGY_EUTRAN;
}
return -1;
}
static bool extract_ss_info(struct qmi_result *result, int *status,
int *lac, int *cellid, int *tech,
struct ofono_network_operator *operator)
@@ -64,7 +50,7 @@ static bool extract_ss_info(struct qmi_result *result, int *status,
const struct qmi_nas_serving_system *ss;
const struct qmi_nas_current_plmn *plmn;
uint8_t i, roaming;
uint16_t value16, len;
uint16_t value16, len, opname_len;
uint32_t value32;
DBG("");
@@ -82,13 +68,13 @@ static bool extract_ss_info(struct qmi_result *result, int *status,
for (i = 0; i < ss->radio_if_count; i++) {
DBG("radio in use %d", ss->radio_if[i]);
*tech = rat_to_tech(ss->radio_if[i]);
*tech = qmi_nas_rat_to_tech(ss->radio_if[i]);
}
if (qmi_result_get_uint8(result, QMI_NAS_RESULT_ROAMING_STATUS,
&roaming)) {
if (ss->status == 1 && roaming == 0)
*status = 5;
*status = NETWORK_REGISTRATION_STATUS_ROAMING;
}
if (!operator)
@@ -100,8 +86,21 @@ static bool extract_ss_info(struct qmi_result *result, int *status,
GUINT16_FROM_LE(plmn->mcc));
snprintf(operator->mnc, OFONO_MAX_MNC_LENGTH + 1, "%02d",
GUINT16_FROM_LE(plmn->mnc));
strncpy(operator->name, plmn->desc, plmn->desc_len);
operator->name[plmn->desc_len] = '\0';
opname_len = plmn->desc_len;
if (opname_len > OFONO_MAX_OPERATOR_NAME_LENGTH)
opname_len = OFONO_MAX_OPERATOR_NAME_LENGTH;
/*
* Telit QMI modems can return non-utf-8 characters in
* plmn-desc. When that happens, libdbus will abort ofono.
* If non-utf-8 characters are detected, use mccmnc string.
*/
if (g_utf8_validate(plmn->desc, opname_len, NULL)) {
strncpy(operator->name, plmn->desc, opname_len);
operator->name[opname_len] = '\0';
} else
snprintf(operator->name, OFONO_MAX_OPERATOR_NAME_LENGTH,
"%s%s", operator->mcc, operator->mnc);
DBG("%s (%s:%s)", operator->name, operator->mcc, operator->mnc);
}
@@ -265,7 +264,7 @@ static void scan_nets_cb(struct qmi_result *result, void *user_data)
DBG("%03d:%02d %d", netrat->info[i].mcc, netrat->info[i].mnc,
netrat->info[i].rat);
list[i].tech = rat_to_tech(netrat->info[i].rat);
list[i].tech = qmi_nas_rat_to_tech(netrat->info[i].rat);
}
done:
@@ -543,7 +542,7 @@ static int qmi_netreg_probe(struct ofono_netreg *netreg,
ofono_netreg_set_data(netreg, data);
qmi_service_create(device, QMI_SERVICE_NAS,
qmi_service_create_shared(device, QMI_SERVICE_NAS,
create_nas_cb, netreg, NULL);
return 0;

View File

@@ -26,6 +26,8 @@
#define _GNU_SOURCE
#include <stdio.h>
#include <ctype.h>
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
@@ -33,12 +35,18 @@
#include <glib.h>
#include <ofono/log.h>
#include "qmi.h"
#include "ctl.h"
typedef void (*qmi_message_func_t)(uint16_t message, uint16_t length,
const void *buffer, void *user_data);
struct discovery {
qmi_destroy_func_t destroy;
};
struct qmi_device {
int ref_count;
int fd;
@@ -49,6 +57,7 @@ struct qmi_device {
GQueue *req_queue;
GQueue *control_queue;
GQueue *service_queue;
GQueue *discovery_queue;
uint8_t next_control_tid;
uint16_t next_service_tid;
qmi_debug_func_t debug_func;
@@ -60,6 +69,10 @@ struct qmi_device {
uint8_t version_count;
GHashTable *service_list;
unsigned int release_users;
qmi_shutdown_func_t shutdown_func;
void *shutdown_user_data;
qmi_destroy_func_t shutdown_destroy;
guint shutdown_source;
};
struct qmi_service {
@@ -209,6 +222,14 @@ static gint __request_compare(gconstpointer a, gconstpointer b)
return req->tid - tid;
}
static void __discovery_free(gpointer data, gpointer user_data)
{
struct discovery *d = data;
qmi_destroy_func_t destroy = d->destroy;
destroy(d);
}
static void __notify_free(gpointer data, gpointer user_data)
{
struct qmi_notify *notify = data;
@@ -313,8 +334,12 @@ static const char *__service_type_to_string(uint8_t type)
return "UIM";
case QMI_SERVICE_PBM:
return "PBM";
case QMI_SERVICE_QCHAT:
return "QCHAT";
case QMI_SERVICE_RMTFS:
return "RMTFS";
case QMI_SERVICE_TEST:
return "TEST";
case QMI_SERVICE_LOC:
return "LOC";
case QMI_SERVICE_SAR:
@@ -326,9 +351,21 @@ static const char *__service_type_to_string(uint8_t type)
case QMI_SERVICE_TS:
return "TS";
case QMI_SERVICE_TMD:
return "TMS";
return "TMD";
case QMI_SERVICE_WDA:
return "WDA";
case QMI_SERVICE_CSVT:
return "CSVT";
case QMI_SERVICE_COEX:
return "COEX";
case QMI_SERVICE_PDC:
return "PDC";
case QMI_SERVICE_RFRPE:
return "RFRPE";
case QMI_SERVICE_DSD:
return "DSD";
case QMI_SERVICE_SSCTL:
return "SSCTL";
case QMI_SERVICE_CAT_OLD:
return "CAT";
case QMI_SERVICE_RMS:
@@ -758,7 +795,7 @@ static void handle_packet(struct qmi_device *device,
tid = GUINT16_FROM_LE(service->transaction);
if (service->type == 0x04 && tid == 0x0000) {
if (service->type == 0x04) {
handle_indication(device, hdr->service, hdr->client,
message, length, data);
return;
@@ -838,6 +875,21 @@ static void read_watch_destroy(gpointer user_data)
device->read_watch = 0;
}
static void __qmi_device_discovery_started(struct qmi_device *device,
struct discovery *d)
{
g_queue_push_tail(device->discovery_queue, d);
}
static void __qmi_device_discovery_complete(struct qmi_device *device,
struct discovery *d)
{
if (g_queue_remove(device->discovery_queue, d) != TRUE)
return;
__discovery_free(d, NULL);
}
static void service_destroy(gpointer data)
{
struct qmi_service *service = data;
@@ -891,6 +943,7 @@ struct qmi_device *qmi_device_new(int fd)
device->req_queue = g_queue_new();
device->control_queue = g_queue_new();
device->service_queue = g_queue_new();
device->discovery_queue = g_queue_new();
device->service_list = g_hash_table_new_full(g_direct_hash,
g_direct_equal, NULL, service_destroy);
@@ -927,6 +980,9 @@ void qmi_device_unref(struct qmi_device *device)
g_queue_foreach(device->req_queue, __request_free, NULL);
g_queue_free(device->req_queue);
g_queue_foreach(device->discovery_queue, __discovery_free, NULL);
g_queue_free(device->discovery_queue);
if (device->write_watch > 0)
g_source_remove(device->write_watch);
@@ -936,6 +992,9 @@ void qmi_device_unref(struct qmi_device *device)
if (device->close_on_unref)
close(device->fd);
if (device->shutdown_source)
g_source_remove(device->shutdown_source);
g_hash_table_destroy(device->service_list);
g_free(device->version_str);
@@ -987,6 +1046,7 @@ static const void *tlv_get(const void *data, uint16_t size,
}
struct discover_data {
struct discovery super;
struct qmi_device *device;
qmi_discover_func_t func;
void *user_data;
@@ -994,6 +1054,21 @@ struct discover_data {
guint timeout;
};
static void discover_data_free(gpointer user_data)
{
struct discover_data *data = user_data;
if (data->timeout) {
g_source_remove(data->timeout);
data->timeout = 0;
}
if (data->destroy)
data->destroy(data->user_data);
g_free(data);
}
static void discover_callback(uint16_t message, uint16_t length,
const void *buffer, void *user_data)
{
@@ -1007,8 +1082,6 @@ static void discover_callback(uint16_t message, uint16_t length,
uint8_t count;
unsigned int i;
g_source_remove(data->timeout);
count = 0;
list = NULL;
@@ -1079,10 +1152,7 @@ done:
if (data->func)
data->func(count, list, data->user_data);
if (data->destroy)
data->destroy(data->user_data);
g_free(data);
__qmi_device_discovery_complete(data->device, &data->super);
}
static gboolean discover_reply(gpointer user_data)
@@ -1096,10 +1166,7 @@ static gboolean discover_reply(gpointer user_data)
data->func(device->version_count,
device->version_list, data->user_data);
if (data->destroy)
data->destroy(data->user_data);
g_free(data);
__qmi_device_discovery_complete(data->device, &data->super);
return FALSE;
}
@@ -1120,13 +1187,15 @@ bool qmi_device_discover(struct qmi_device *device, qmi_discover_func_t func,
if (!data)
return false;
data->super.destroy = discover_data_free;
data->device = device;
data->func = func;
data->user_data = user_data;
data->destroy = destroy;
if (device->version_list) {
g_timeout_add_seconds(0, discover_reply, data);
data->timeout = g_timeout_add_seconds(0, discover_reply, data);
__qmi_device_discovery_started(device, &data->super);
return true;
}
@@ -1147,6 +1216,7 @@ bool qmi_device_discover(struct qmi_device *device, qmi_discover_func_t func,
__request_submit(device, req, hdr->transaction);
data->timeout = g_timeout_add_seconds(5, discover_reply, data);
__qmi_device_discovery_started(device, &data->super);
return true;
}
@@ -1177,63 +1247,249 @@ static void release_client(struct qmi_device *device,
__request_submit(device, req, hdr->transaction);
}
struct shutdown_data {
struct qmi_device *device;
qmi_shutdown_func_t func;
void *user_data;
qmi_destroy_func_t destroy;
};
static gboolean shutdown_reply(gpointer user_data)
static void shutdown_destroy(gpointer user_data)
{
struct shutdown_data *data = user_data;
struct qmi_device *device = user_data;
if (data->func)
data->func(data->user_data);
if (device->shutdown_destroy)
device->shutdown_destroy(device->shutdown_user_data);
g_free(data);
return FALSE;
device->shutdown_source = 0;
}
static gboolean shutdown_timeout(gpointer user_data)
static gboolean shutdown_callback(gpointer user_data)
{
struct shutdown_data *data = user_data;
struct qmi_device *device = data->device;
struct qmi_device *device = user_data;
if (device->release_users > 0)
return TRUE;
return shutdown_reply(data);
if (device->shutdown_func)
device->shutdown_func(device->shutdown_user_data);
return FALSE;
}
bool qmi_device_shutdown(struct qmi_device *device, qmi_shutdown_func_t func,
void *user_data, qmi_destroy_func_t destroy)
{
struct shutdown_data *data;
if (!device)
return false;
if (device->shutdown_source > 0)
return false;
__debug_device(device, "device %p shutdown", device);
data = g_try_new0(struct shutdown_data, 1);
if (!data)
device->shutdown_source = g_timeout_add_seconds_full(G_PRIORITY_DEFAULT,
0, shutdown_callback, device,
shutdown_destroy);
if (device->shutdown_source == 0)
return false;
data->device = device;
data->func = func;
data->user_data = user_data;
data->destroy = destroy;
if (device->release_users > 0)
g_timeout_add_seconds(0, shutdown_timeout, data);
else
g_timeout_add_seconds(0, shutdown_reply, data);
device->shutdown_func = func;
device->shutdown_user_data = user_data;
device->shutdown_destroy = destroy;
return true;
}
static bool get_device_file_name(struct qmi_device *device,
char *file_name, int size)
{
pid_t pid;
char temp[100];
ssize_t result;
if (size <= 0)
return false;
pid = getpid();
snprintf(temp, 100, "/proc/%d/fd/%d", (int) pid, device->fd);
temp[99] = 0;
result = readlink(temp, file_name, size - 1);
if (result == -1 || result >= size - 1) {
DBG("Error %d in readlink", errno);
return false;
}
file_name[result] = 0;
return true;
}
static char *get_first_dir_in_directory(char *dir_path)
{
DIR *dir;
struct dirent *dir_entry;
char *dir_name = NULL;
dir = opendir(dir_path);
if (!dir)
return NULL;
dir_entry = readdir(dir);
while ((dir_entry != NULL)) {
if (dir_entry->d_type == DT_DIR &&
strcmp(dir_entry->d_name, ".") != 0 &&
strcmp(dir_entry->d_name, "..") != 0) {
dir_name = g_strdup(dir_entry->d_name);
break;
}
dir_entry = readdir(dir);
}
closedir(dir);
return dir_name;
}
static char *get_device_interface(struct qmi_device *device)
{
char * const driver_names[] = { "usbmisc", "usb" };
unsigned int i;
char file_path[PATH_MAX];
char *file_name;
char *interface = NULL;
if (!get_device_file_name(device, file_path, sizeof(file_path)))
return NULL;
file_name = basename(file_path);
for (i = 0; i < G_N_ELEMENTS(driver_names) && !interface; i++) {
gchar *sysfs_path;
sysfs_path = g_strdup_printf("/sys/class/%s/%s/device/net/",
driver_names[i], file_name);
interface = get_first_dir_in_directory(sysfs_path);
g_free(sysfs_path);
}
return interface;
}
enum qmi_device_expected_data_format qmi_device_get_expected_data_format(
struct qmi_device *device)
{
char *sysfs_path = NULL;
char *interface = NULL;
int fd = -1;
char value;
enum qmi_device_expected_data_format expected =
QMI_DEVICE_EXPECTED_DATA_FORMAT_UNKNOWN;
if (!device)
goto done;
interface = get_device_interface(device);
if (!interface) {
DBG("Error while getting interface name");
goto done;
}
/* Build sysfs file path and open it */
sysfs_path = g_strdup_printf("/sys/class/net/%s/qmi/raw_ip", interface);
fd = open(sysfs_path, O_RDONLY);
if (fd < 0) {
/* maybe not supported by kernel */
DBG("Error %d in open(%s)", errno, sysfs_path);
goto done;
}
if (read(fd, &value, 1) != 1) {
DBG("Error %d in read(%s)", errno, sysfs_path);
goto done;
}
if (value == 'Y')
expected = QMI_DEVICE_EXPECTED_DATA_FORMAT_RAW_IP;
else if (value == 'N')
expected = QMI_DEVICE_EXPECTED_DATA_FORMAT_802_3;
else
DBG("Unexpected sysfs file contents");
done:
if (fd >= 0)
close(fd);
if (sysfs_path)
g_free(sysfs_path);
if (interface)
g_free(interface);
return expected;
}
bool qmi_device_set_expected_data_format(struct qmi_device *device,
enum qmi_device_expected_data_format format)
{
bool res = false;
char *sysfs_path = NULL;
char *interface = NULL;
int fd = -1;
char value;
if (!device)
goto done;
switch (format) {
case QMI_DEVICE_EXPECTED_DATA_FORMAT_802_3:
value = 'N';
break;
case QMI_DEVICE_EXPECTED_DATA_FORMAT_RAW_IP:
value = 'Y';
break;
default:
DBG("Unhandled format: %d", (int) format);
goto done;
}
interface = get_device_interface(device);
if (!interface) {
DBG("Error while getting interface name");
goto done;
}
/* Build sysfs file path and open it */
sysfs_path = g_strdup_printf("/sys/class/net/%s/qmi/raw_ip", interface);
fd = open(sysfs_path, O_WRONLY);
if (fd < 0) {
/* maybe not supported by kernel */
DBG("Error %d in open(%s)", errno, sysfs_path);
goto done;
}
if (write(fd, &value, 1) != 1) {
DBG("Error %d in write(%s)", errno, sysfs_path);
goto done;
}
res = true;
done:
if (fd >= 0)
close(fd);
if (sysfs_path)
g_free(sysfs_path);
if (interface)
g_free(interface);
return res;
}
struct qmi_param *qmi_param_new(void)
{
struct qmi_param *param;
@@ -1501,6 +1757,7 @@ bool qmi_result_get_uint64(struct qmi_result *result, uint8_t type,
}
struct service_create_data {
struct discovery super;
struct qmi_device *device;
bool shared;
uint8_t type;
@@ -1512,16 +1769,29 @@ struct service_create_data {
guint timeout;
};
static gboolean service_create_reply(gpointer user_data)
static void service_create_data_free(gpointer user_data)
{
struct service_create_data *data = user_data;
data->func(NULL, data->user_data);
if (data->timeout) {
g_source_remove(data->timeout);
data->timeout = 0;
}
if (data->destroy)
data->destroy(data->user_data);
g_free(data);
}
static gboolean service_create_reply(gpointer user_data)
{
struct service_create_data *data = user_data;
data->timeout = 0;
data->func(NULL, data->user_data);
__qmi_device_discovery_complete(data->device, &data->super);
return FALSE;
}
@@ -1537,8 +1807,6 @@ static void service_create_callback(uint16_t message, uint16_t length,
uint16_t len;
unsigned int hash_id;
g_source_remove(data->timeout);
result_code = tlv_get(buffer, length, 0x02, &len);
if (!result_code)
goto done;
@@ -1580,13 +1848,9 @@ static void service_create_callback(uint16_t message, uint16_t length,
done:
data->func(service, data->user_data);
qmi_service_unref(service);
if (data->destroy)
data->destroy(data->user_data);
g_free(data);
__qmi_device_discovery_complete(data->device, &data->super);
}
static void service_create_discover(uint8_t count,
@@ -1617,7 +1881,9 @@ static void service_create_discover(uint8_t count,
if (data->timeout > 0)
g_source_remove(data->timeout);
g_timeout_add_seconds(0, service_create_reply, data);
data->timeout = g_timeout_add_seconds(0,
service_create_reply, data);
__qmi_device_discovery_started(device, &data->super);
return;
}
@@ -1640,6 +1906,7 @@ static bool service_create(struct qmi_device *device, bool shared,
if (!data)
return false;
data->super.destroy = service_create_data_free;
data->device = device;
data->shared = shared;
data->type = type;
@@ -1662,6 +1929,7 @@ static bool service_create(struct qmi_device *device, bool shared,
done:
data->timeout = g_timeout_add_seconds(8, service_create_reply, data);
__qmi_device_discovery_started(device, &data->super);
return true;
}
@@ -1680,17 +1948,23 @@ bool qmi_service_create(struct qmi_device *device,
}
struct service_create_shared_data {
struct discovery super;
struct qmi_service *service;
struct qmi_device *device;
qmi_create_func_t func;
void *user_data;
qmi_destroy_func_t destroy;
guint timeout;
};
static gboolean service_create_shared_reply(gpointer user_data)
static void service_create_shared_data_free(gpointer user_data)
{
struct service_create_shared_data *data = user_data;
data->func(data->service, data->user_data);
if (data->timeout) {
g_source_remove(data->timeout);
data->timeout = 0;
}
qmi_service_unref(data->service);
@@ -1698,6 +1972,16 @@ static gboolean service_create_shared_reply(gpointer user_data)
data->destroy(data->user_data);
g_free(data);
}
static gboolean service_create_shared_reply(gpointer user_data)
{
struct service_create_shared_data *data = user_data;
data->timeout = 0;
data->func(data->service, data->user_data);
__qmi_device_discovery_complete(data->device, &data->super);
return FALSE;
}
@@ -1724,13 +2008,16 @@ bool qmi_service_create_shared(struct qmi_device *device,
if (!data)
return false;
data->super.destroy = service_create_shared_data_free;
data->service = qmi_service_ref(service);
data->device = device;
data->func = func;
data->user_data = user_data;
data->destroy = destroy;
g_timeout_add(0, service_create_shared_reply, data);
data->timeout = g_timeout_add(0,
service_create_shared_reply, data);
__qmi_device_discovery_started(device, &data->super);
return 0;
}

View File

@@ -35,18 +35,32 @@
#define QMI_SERVICE_CAT 10 /* Card application toolkit service */
#define QMI_SERVICE_UIM 11 /* UIM service */
#define QMI_SERVICE_PBM 12 /* Phonebook service */
#define QMI_SERVICE_QCHAT 13
#define QMI_SERVICE_RMTFS 14 /* Remote file system service */
#define QMI_SERVICE_TEST 15
#define QMI_SERVICE_LOC 16 /* Location service */
#define QMI_SERVICE_SAR 17 /* Specific absorption rate service */
#define QMI_SERVICE_CSD 20 /* Core sound driver service */
#define QMI_SERVICE_EFS 21 /* Embedded file system service */
#define QMI_SERVICE_TS 23 /* Thermal sensors service */
#define QMI_SERVICE_TMD 24 /* Thermal mitigation device service */
#define QMI_SERVICE_WDA 26 /* Wireless data administrative service */
#define QMI_SERVICE_CSVT 29
#define QMI_SERVICE_COEX 34
#define QMI_SERVICE_PDC 36 /* Persistent device configuration service */
#define QMI_SERVICE_RFRPE 41
#define QMI_SERVICE_DSD 42
#define QMI_SERVICE_SSCTL 43
#define QMI_SERVICE_CAT_OLD 224 /* Card application toolkit service */
#define QMI_SERVICE_RMS 225 /* Remote management service */
#define QMI_SERVICE_OMA 226 /* OMA device management service */
enum qmi_device_expected_data_format {
QMI_DEVICE_EXPECTED_DATA_FORMAT_UNKNOWN,
QMI_DEVICE_EXPECTED_DATA_FORMAT_802_3,
QMI_DEVICE_EXPECTED_DATA_FORMAT_RAW_IP,
};
struct qmi_version {
uint8_t type;
uint16_t major;
@@ -82,6 +96,10 @@ bool qmi_device_discover(struct qmi_device *device, qmi_discover_func_t func,
bool qmi_device_shutdown(struct qmi_device *device, qmi_shutdown_func_t func,
void *user_data, qmi_destroy_func_t destroy);
enum qmi_device_expected_data_format qmi_device_get_expected_data_format(
struct qmi_device *device);
bool qmi_device_set_expected_data_format(struct qmi_device *device,
enum qmi_device_expected_data_format format);
struct qmi_param;

View File

@@ -74,7 +74,8 @@ static int qmi_radio_settings_probe(struct ofono_radio_settings *rs,
ofono_radio_settings_set_data(rs, data);
qmi_service_create(device, QMI_SERVICE_NAS, create_nas_cb, rs, NULL);
qmi_service_create_shared(device, QMI_SERVICE_NAS,
create_nas_cb, rs, NULL);
return 0;

View File

@@ -30,6 +30,7 @@
#include <ofono/sim.h>
#include "qmi.h"
#include "dms.h"
#include "uim.h"
#include "qmimodem.h"
@@ -38,15 +39,36 @@
#define EF_STATUS_INVALIDATED 0
#define EF_STATUS_VALID 1
struct sim_data {
struct qmi_service *uim;
uint32_t event_mask;
/* max number of retry of commands that can temporary fail */
#define MAX_RETRY_COUNT 100
enum get_card_status_result {
GET_CARD_STATUS_RESULT_OK, /* No error */
GET_CARD_STATUS_RESULT_ERROR, /* Definitive error */
GET_CARD_STATUS_RESULT_TEMP_ERROR, /* error, a retry could work */
};
/* information from QMI_UIM_GET_CARD_STATUS command */
struct sim_status {
uint8_t card_state;
uint8_t app_type;
uint8_t passwd_state;
int retries[OFONO_SIM_PASSWORD_INVALID];
};
struct sim_data {
struct qmi_device *qmi_dev;
struct qmi_service *dms;
struct qmi_service *uim;
uint32_t event_mask;
uint8_t app_type;
uint32_t retry_count;
guint poll_source;
};
static void qmi_query_passwd_state(struct ofono_sim *sim,
ofono_sim_passwd_cb_t cb, void *user_data);
static int create_fileid_data(uint8_t app_type, int fileid,
const unsigned char *path,
unsigned int path_len,
@@ -146,7 +168,7 @@ static void qmi_read_attributes(struct ofono_sim *sim, int fileid,
{
struct sim_data *data = ofono_sim_get_data(sim);
struct cb_data *cbd = cb_data_new(cb, user_data);
unsigned char aid_data[2] = { 0x06, 0x00 };
unsigned char aid_data[2] = { 0x00, 0x00 };
unsigned char fileid_data[9];
int fileid_len;
struct qmi_param *param;
@@ -211,7 +233,7 @@ static void qmi_read_transparent(struct ofono_sim *sim,
{
struct sim_data *data = ofono_sim_get_data(sim);
struct cb_data *cbd = cb_data_new(cb, user_data);
unsigned char aid_data[2] = { 0x06, 0x00 };
unsigned char aid_data[2] = { 0x00, 0x00 };
unsigned char read_data[4];
unsigned char fileid_data[9];
int fileid_len;
@@ -257,7 +279,7 @@ static void qmi_read_record(struct ofono_sim *sim,
{
struct sim_data *data = ofono_sim_get_data(sim);
struct cb_data *cbd = cb_data_new(cb, user_data);
unsigned char aid_data[2] = { 0x06, 0x00 };
unsigned char aid_data[2] = { 0x00, 0x00 };
unsigned char read_data[4];
unsigned char fileid_data[9];
int fileid_len;
@@ -295,76 +317,96 @@ error:
g_free(cbd);
}
static void qmi_query_passwd_state(struct ofono_sim *sim,
ofono_sim_passwd_cb_t cb, void *user_data)
static void get_imsi_cb(struct qmi_result *result, void *user_data)
{
struct sim_data *data = ofono_sim_get_data(sim);
struct cb_data *cbd = user_data;
ofono_sim_imsi_cb_t cb = cbd->cb;
char *str;
DBG("passwd state %d", data->passwd_state);
DBG("");
if (data->passwd_state == OFONO_SIM_PASSWORD_INVALID) {
CALLBACK_WITH_FAILURE(cb, -1, user_data);
if (qmi_result_set_error(result, NULL)) {
CALLBACK_WITH_FAILURE(cb, NULL, cbd->data);
return;
}
CALLBACK_WITH_SUCCESS(cb, data->passwd_state, user_data);
}
static void qmi_query_pin_retries(struct ofono_sim *sim,
ofono_sim_pin_retries_cb_t cb, void *user_data)
{
struct sim_data *data = ofono_sim_get_data(sim);
DBG("passwd state %d", data->passwd_state);
if (data->passwd_state == OFONO_SIM_PASSWORD_INVALID) {
CALLBACK_WITH_FAILURE(cb, NULL, user_data);
str = qmi_result_get_string(result, QMI_DMS_RESULT_IMSI);
if (!str) {
CALLBACK_WITH_FAILURE(cb, NULL, cbd->data);
return;
}
CALLBACK_WITH_SUCCESS(cb, data->retries, user_data);
CALLBACK_WITH_SUCCESS(cb, str, cbd->data);
qmi_free(str);
}
static void card_setup(const struct qmi_uim_slot_info *slot,
static void qmi_read_imsi(struct ofono_sim *sim,
ofono_sim_imsi_cb_t cb, void *user_data)
{
struct sim_data *data = ofono_sim_get_data(sim);
struct cb_data *cbd = cb_data_new(cb, user_data);
DBG("");
if (qmi_service_send(data->dms, QMI_DMS_GET_IMSI, NULL,
get_imsi_cb, cbd, g_free) > 0)
return;
CALLBACK_WITH_FAILURE(cb, NULL, cbd->data);
g_free(cbd);
}
/* Return true if a retry could give another (better) result */
static bool get_card_status(const struct qmi_uim_slot_info *slot,
const struct qmi_uim_app_info1 *info1,
const struct qmi_uim_app_info2 *info2,
struct sim_data *data)
struct sim_status *sim_stat)
{
data->card_state = slot->card_state;
data->app_type = info1->app_type;
bool need_retry = false;
sim_stat->card_state = slot->card_state;
sim_stat->app_type = info1->app_type;
switch (info1->app_state) {
case 0x02: /* PIN1 or UPIN is required */
data->passwd_state = OFONO_SIM_PASSWORD_SIM_PIN;
sim_stat->passwd_state = OFONO_SIM_PASSWORD_SIM_PIN;
break;
case 0x03: /* PUK1 or PUK for UPIN is required */
data->passwd_state = OFONO_SIM_PASSWORD_SIM_PUK;
sim_stat->passwd_state = OFONO_SIM_PASSWORD_SIM_PUK;
break;
case 0x04: /* Personalization state must be checked. */
/* This is temporary, we could retry and get another result */
sim_stat->passwd_state = OFONO_SIM_PASSWORD_INVALID;
need_retry = true;
break;
case 0x07: /* Ready */
data->passwd_state = OFONO_SIM_PASSWORD_NONE;
sim_stat->passwd_state = OFONO_SIM_PASSWORD_NONE;
break;
default:
data->passwd_state = OFONO_SIM_PASSWORD_INVALID;
DBG("info1->app_state:0x%x: OFONO_SIM_PASSWORD_INVALID",
info1->app_state);
sim_stat->passwd_state = OFONO_SIM_PASSWORD_INVALID;
break;
}
data->retries[OFONO_SIM_PASSWORD_SIM_PIN] = info2->pin1_retries;
data->retries[OFONO_SIM_PASSWORD_SIM_PUK] = info2->puk1_retries;
sim_stat->retries[OFONO_SIM_PASSWORD_SIM_PIN] = info2->pin1_retries;
sim_stat->retries[OFONO_SIM_PASSWORD_SIM_PUK] = info2->puk1_retries;
data->retries[OFONO_SIM_PASSWORD_SIM_PIN2] = info2->pin2_retries;
data->retries[OFONO_SIM_PASSWORD_SIM_PUK2] = info2->puk2_retries;
sim_stat->retries[OFONO_SIM_PASSWORD_SIM_PIN2] = info2->pin2_retries;
sim_stat->retries[OFONO_SIM_PASSWORD_SIM_PUK2] = info2->puk2_retries;
return need_retry;
}
static void get_card_status_cb(struct qmi_result *result, void *user_data)
static enum get_card_status_result handle_get_card_status_result(
struct qmi_result *result, struct sim_status *sim_stat)
{
struct ofono_sim *sim = user_data;
struct sim_data *data = ofono_sim_get_data(sim);
const void *ptr;
const struct qmi_uim_card_status *status;
uint16_t len, offset;
uint8_t i;
DBG("");
enum get_card_status_result res = GET_CARD_STATUS_RESULT_ERROR;
if (qmi_result_set_error(result, NULL))
goto done;
@@ -397,15 +439,211 @@ static void get_card_status_cb(struct qmi_result *result, void *user_data)
index = GUINT16_FROM_LE(status->index_gw_pri);
if ((index & 0xff) == i && (index >> 8) == n)
card_setup(slot, info1, info2, data);
if ((index & 0xff) == i && (index >> 8) == n) {
if (get_card_status(slot, info1, info2,
sim_stat))
res = GET_CARD_STATUS_RESULT_TEMP_ERROR;
else
res = GET_CARD_STATUS_RESULT_OK;
}
}
}
done:
return res;
}
static gboolean query_passwd_state_retry(gpointer userdata)
{
struct cb_data *cbd = userdata;
ofono_sim_passwd_cb_t cb = cbd->cb;
struct ofono_sim *sim = cbd->user;
struct sim_data *data = ofono_sim_get_data(sim);
data->poll_source = 0;
qmi_query_passwd_state(sim, cb, cbd->data);
return FALSE;
}
static void query_passwd_state_cb(struct qmi_result *result,
void *user_data)
{
struct cb_data *cbd = user_data;
ofono_sim_passwd_cb_t cb = cbd->cb;
struct ofono_sim *sim = cbd->user;
struct sim_data *data = ofono_sim_get_data(sim);
struct sim_status sim_stat;
enum get_card_status_result res;
struct cb_data *retry_cbd;
res = handle_get_card_status_result(result, &sim_stat);
switch (res) {
case GET_CARD_STATUS_RESULT_OK:
DBG("passwd state %d", sim_stat.passwd_state);
data->retry_count = 0;
CALLBACK_WITH_SUCCESS(cb, sim_stat.passwd_state, cbd->data);
break;
case GET_CARD_STATUS_RESULT_TEMP_ERROR:
data->retry_count++;
if (data->retry_count > MAX_RETRY_COUNT) {
DBG("Failed after %d attempts", data->retry_count);
data->retry_count = 0;
CALLBACK_WITH_FAILURE(cb, -1, cbd->data);
} else {
DBG("Retry command");
retry_cbd = cb_data_new(cb, cbd->data);
retry_cbd->user = sim;
data->poll_source = g_timeout_add(20,
query_passwd_state_retry,
retry_cbd);
}
break;
case GET_CARD_STATUS_RESULT_ERROR:
DBG("Command failed");
data->retry_count = 0;
CALLBACK_WITH_FAILURE(cb, -1, cbd->data);
break;
}
}
static void qmi_query_passwd_state(struct ofono_sim *sim,
ofono_sim_passwd_cb_t cb, void *user_data)
{
struct sim_data *data = ofono_sim_get_data(sim);
struct cb_data *cbd = cb_data_new(cb, user_data);
DBG("");
cbd->user = sim;
if (qmi_service_send(data->uim, QMI_UIM_GET_CARD_STATUS, NULL,
query_passwd_state_cb, cbd, g_free) > 0)
return;
CALLBACK_WITH_FAILURE(cb, -1, cbd->data);
g_free(cbd);
}
static void query_pin_retries_cb(struct qmi_result *result, void *user_data)
{
struct cb_data *cbd = user_data;
ofono_sim_pin_retries_cb_t cb = cbd->cb;
struct sim_status sim_stat;
DBG("");
if (handle_get_card_status_result(result, &sim_stat) !=
GET_CARD_STATUS_RESULT_OK) {
CALLBACK_WITH_FAILURE(cb, NULL, cbd->data);
return;
}
CALLBACK_WITH_SUCCESS(cb, sim_stat.retries, cbd->data);
}
static void qmi_query_pin_retries(struct ofono_sim *sim,
ofono_sim_pin_retries_cb_t cb, void *user_data)
{
struct sim_data *data = ofono_sim_get_data(sim);
struct cb_data *cbd = cb_data_new(cb, user_data);
DBG("");
if (qmi_service_send(data->uim, QMI_UIM_GET_CARD_STATUS, NULL,
query_pin_retries_cb, cbd, g_free) > 0)
return;
CALLBACK_WITH_FAILURE(cb, NULL, cbd->data);
g_free(cbd);
}
static void pin_send_cb(struct qmi_result *result, void *user_data)
{
struct cb_data *cbd = user_data;
ofono_sim_lock_unlock_cb_t cb = cbd->cb;
DBG("");
if (qmi_result_set_error(result, NULL)) {
CALLBACK_WITH_FAILURE(cb, cbd->data);
return;
}
CALLBACK_WITH_SUCCESS(cb, cbd->data);
}
static void qmi_pin_send(struct ofono_sim *sim, const char *passwd,
ofono_sim_lock_unlock_cb_t cb, void *user_data)
{
struct sim_data *data = ofono_sim_get_data(sim);
struct cb_data *cbd = cb_data_new(cb, user_data);
int passwd_len;
struct qmi_param *param;
struct qmi_uim_param_message_info *info_data;
unsigned char session_info_data[2];
DBG("");
if (!passwd)
goto error;
passwd_len = strlen(passwd);
if (passwd_len <= 0 || passwd_len > 0xFF)
goto error;
param = qmi_param_new();
if (!param)
goto error;
/* param info */
info_data = alloca(2 + passwd_len);
info_data->pin_id = 0x01; /* PIN 1 */
info_data->length = (uint8_t) passwd_len;
memcpy(info_data->pin_value, passwd, passwd_len);
qmi_param_append(param, QMI_UIM_PARAM_MESSAGE_INFO, 2 + passwd_len,
info_data);
/* param Session Information */
session_info_data[0] = 0x6;
session_info_data[1] = 0x0;
qmi_param_append(param, QMI_UIM_PARAM_MESSAGE_SESSION_INFO, 2,
session_info_data);
if (qmi_service_send(data->uim, QMI_UIM_VERIFY_PIN, param,
pin_send_cb, cbd, g_free) > 0)
return;
qmi_param_free(param);
error:
CALLBACK_WITH_FAILURE(cb, cbd->data);
g_free(cbd);
}
static void get_card_status_cb(struct qmi_result *result, void *user_data)
{
struct ofono_sim *sim = user_data;
struct sim_data *data = ofono_sim_get_data(sim);
struct sim_status sim_stat;
DBG("");
if (handle_get_card_status_result(result, &sim_stat) !=
GET_CARD_STATUS_RESULT_OK) {
data->app_type = 0; /* Unknown */
sim_stat.card_state = 0x00; /* Absent */
} else {
data->app_type = sim_stat.app_type;
}
ofono_sim_register(sim);
switch (data->card_state) {
switch (sim_stat.card_state) {
case 0x00: /* Absent */
case 0x02: /* Error */
break;
@@ -465,30 +703,44 @@ static void create_uim_cb(struct qmi_service *service, void *user_data)
return;
error:
qmi_service_unref(data->uim);
ofono_sim_remove(sim);
}
static void create_dms_cb(struct qmi_service *service, void *user_data)
{
struct ofono_sim *sim = user_data;
struct sim_data *data = ofono_sim_get_data(sim);
DBG("");
if (!service) {
ofono_error("Failed to request DMS service");
ofono_sim_remove(sim);
return;
}
data->dms = qmi_service_ref(service);
qmi_service_create(data->qmi_dev, QMI_SERVICE_UIM, create_uim_cb, sim,
NULL);
}
static int qmi_sim_probe(struct ofono_sim *sim,
unsigned int vendor, void *user_data)
{
struct qmi_device *device = user_data;
struct sim_data *data;
int i;
DBG("");
data = g_new0(struct sim_data, 1);
data->passwd_state = OFONO_SIM_PASSWORD_INVALID;
for (i = 0; i < OFONO_SIM_PASSWORD_INVALID; i++)
data->retries[i] = -1;
data->qmi_dev = device;
ofono_sim_set_data(sim, data);
qmi_service_create(device, QMI_SERVICE_UIM, create_uim_cb, sim, NULL);
qmi_service_create_shared(device, QMI_SERVICE_DMS,
create_dms_cb, sim, NULL);
return 0;
}
@@ -501,9 +753,18 @@ static void qmi_sim_remove(struct ofono_sim *sim)
ofono_sim_set_data(sim, NULL);
qmi_service_unregister_all(data->uim);
if (data->poll_source > 0)
g_source_remove(data->poll_source);
qmi_service_unref(data->uim);
if (data->uim) {
qmi_service_unregister_all(data->uim);
qmi_service_unref(data->uim);
data->uim = NULL;
}
if (data->dms) {
qmi_service_unregister_all(data->dms);
qmi_service_unref(data->dms);
}
g_free(data);
}
@@ -516,8 +777,10 @@ static struct ofono_sim_driver driver = {
.read_file_transparent = qmi_read_transparent,
.read_file_linear = qmi_read_record,
.read_file_cyclic = qmi_read_record,
.read_imsi = qmi_read_imsi,
.query_passwd_state = qmi_query_passwd_state,
.query_pin_retries = qmi_query_pin_retries,
.send_passwd = qmi_pin_send,
};
void qmi_sim_init(void)

View File

@@ -25,6 +25,8 @@
#define QMI_UIM_WRITE_RECORD 35 /* Write a record */
#define QMI_UIM_GET_FILE_ATTRIBUTES 36 /* Get file attributes */
#define QMI_UIM_VERIFY_PIN 38 /* Verify PIN */
#define QMI_UIM_EVENT_REGISTRATION 46 /* Register for indications */
#define QMI_UIM_GET_CARD_STATUS 47 /* Get card status */
@@ -91,3 +93,12 @@ struct qmi_uim_file_attributes {
uint16_t raw_len;
uint8_t raw_value[0];
} __attribute__((__packed__));
/* Verify PIN parameter */
#define QMI_UIM_PARAM_MESSAGE_SESSION_INFO 0x01
#define QMI_UIM_PARAM_MESSAGE_INFO 0x02
struct qmi_uim_param_message_info {
uint8_t pin_id;
uint8_t length;
uint8_t pin_value[0];
} __attribute__((__packed__));

View File

@@ -0,0 +1,25 @@
/*
*
* oFono - Open Source Telephony
*
* Copyright (C) 2017 Kerlink SA. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
#define QMI_WDA_SET_DATA_FORMAT 32 /* Set data format */
#define QMI_WDA_GET_DATA_FORMAT 33 /* Get data format */
/* Get and set data format interface */
#define QMI_WDA_LL_PROTOCOL 0x11 /* uint32_t */
#define QMI_WDA_DATA_LINK_PROTOCOL_UNKNOWN 0
#define QMI_WDA_DATA_LINK_PROTOCOL_802_3 1
#define QMI_WDA_DATA_LINK_PROTOCOL_RAW_IP 2

View File

@@ -30,6 +30,13 @@
/* Start WDS network interface */
#define QMI_WDS_PARAM_APN 0x14 /* string */
#define QMI_WDS_PARAM_IP_FAMILY 0x19 /* uint8 */
#define QMI_WDS_PARAM_USERNAME 0x17 /* string */
#define QMI_WDS_PARAM_PASSWORD 0x18 /* string */
#define QMI_WDS_PARAM_AUTHENTICATION_PREFERENCE 0x16 /* uint8 */
#define QMI_WDS_AUTHENTICATION_NONE 0x0
#define QMI_WDS_AUTHENTICATION_PAP 0x1
#define QMI_WDS_AUTHENTICATION_CHAP 0x2
#define QMI_WDS_RESULT_PKT_HANDLE 0x01 /* uint32 */
@@ -51,10 +58,12 @@ struct qmi_wds_notify_conn_status {
/* Get the runtime data session settings */
#define QMI_WDS_RESULT_PDP_TYPE 0x11 /* uint8 */
#define QMI_WDS_RESULT_APN 0x14 /* string */
#define QMI_WDS_RESULT_PRIMARY_DNS 0x15 /* uint32 IPv4 */
#define QMI_WDS_RESULT_SECONDARY_DNS 0x16 /* uint32 IPv4 */
#define QMI_WDS_RESULT_IP_ADDRESS 0x1e /* uint32 IPv4 */
#define QMI_WDS_RESULT_GATEWAY 0x20 /* uint32 IPv4 */
#define QMI_WDS_RESULT_GATEWAY_NETMASK 0x21 /* uint32 IPv4 */
#define QMI_WDS_RESULT_IP_FAMILY 0x2b /* uint8 */
#define QMI_WDS_PDP_TYPE_IPV4 0x00

View File

@@ -0,0 +1,283 @@
/*
* oFono - Open Source Telephony - RIL-based devices
*
* Copyright (C) 2015-2017 Jolla Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "ril_plugin.h"
#include "ril_util.h"
#include "ril_log.h"
#include "common.h"
/* See 3GPP 27.007 7.4 for possible values */
#define RIL_MAX_SERVICE_LENGTH 3
/*
* ril.h does not state that string count must be given, but that is
* still expected by the modem
*/
#define RIL_QUERY_STRING_COUNT 4
#define RIL_SET_STRING_COUNT 5
#define RIL_SET_PW_STRING_COUNT 3
struct ril_call_barring {
GRilIoQueue *q;
guint timer_id;
};
struct ril_call_barring_cbd {
struct ril_call_barring *bd;
union _ofono_call_barring_cb {
ofono_call_barring_query_cb_t query;
ofono_call_barring_set_cb_t set;
gpointer ptr;
} cb;
gpointer data;
};
#define ril_call_barring_cbd_free g_free
static inline struct ril_call_barring *ril_call_barring_get_data(
struct ofono_call_barring *b)
{
return ofono_call_barring_get_data(b);
}
static struct ril_call_barring_cbd *ril_call_barring_cbd_new(
struct ril_call_barring *bd, void *cb, void *data)
{
struct ril_call_barring_cbd *cbd;
cbd = g_new0(struct ril_call_barring_cbd, 1);
cbd->bd = bd;
cbd->cb.ptr = cb;
cbd->data = data;
return cbd;
}
static inline void ril_call_barring_submit_request(struct ril_call_barring *bd,
GRilIoRequest* req, guint code, GRilIoChannelResponseFunc response,
void *cb, void *data)
{
grilio_queue_send_request_full(bd->q, req, code, response,
ril_call_barring_cbd_free,
ril_call_barring_cbd_new(bd, cb, data));
}
static void ril_call_barring_query_cb(GRilIoChannel *io, int status,
const void *data, guint len, void *user_data)
{
struct ofono_error error;
struct ril_call_barring_cbd *cbd = user_data;
ofono_call_barring_query_cb_t cb = cbd->cb.query;
if (status == RIL_E_SUCCESS) {
int bearer_class = 0;
GRilIoParser rilp;
/*
* Services for which the specified barring facility is active.
* "0" means "disabled for all, -1 if unknown"
*/
grilio_parser_init(&rilp, data, len);
grilio_parser_get_int32(&rilp, NULL); /* count */
grilio_parser_get_int32(&rilp, &bearer_class);
DBG("Active services: %d", bearer_class);
cb(ril_error_ok(&error), bearer_class, cbd->data);
} else {
ofono_error("Call Barring query error %d", status);
cb(ril_error_failure(&error), 0, cbd->data);
}
}
static void ril_call_barring_query(struct ofono_call_barring *b,
const char *lock, int cls,
ofono_call_barring_query_cb_t cb, void *data)
{
struct ril_call_barring *bd = ofono_call_barring_get_data(b);
char cls_textual[RIL_MAX_SERVICE_LENGTH];
GRilIoRequest *req = grilio_request_new();
DBG("lock: %s, services to query: %d", lock, cls);
/*
* RIL modems do not support 7 as default bearer class. According to
* the 22.030 Annex C: When service code is not given it corresponds to
* "All tele and bearer services"
*/
if (cls == BEARER_CLASS_DEFAULT) {
cls = SERVICE_CLASS_NONE;
}
sprintf(cls_textual, "%d", cls);
/*
* See 3GPP 27.007 7.4 for parameter descriptions.
* According to ril.h password should be empty string "" when not
* needed, but in reality we only need to give string length as 0
*/
grilio_request_append_int32(req, RIL_QUERY_STRING_COUNT);
grilio_request_append_utf8(req, lock); /* Facility code */
grilio_request_append_int32(req, 0); /* Password length */
grilio_request_append_utf8(req, cls_textual);
grilio_request_append_utf8(req, NULL); /* AID (not yet supported) */
ril_call_barring_submit_request(bd, req,
RIL_REQUEST_QUERY_FACILITY_LOCK,
ril_call_barring_query_cb, cb, data);
grilio_request_unref(req);
}
static void ril_call_barring_set_cb(GRilIoChannel *io, int status,
const void *data, guint len, void *user_data)
{
struct ofono_error error;
struct ril_call_barring_cbd *cbd = user_data;
ofono_call_barring_set_cb_t cb = cbd->cb.set;
if (status == RIL_E_SUCCESS) {
cb(ril_error_ok(&error), cbd->data);
} else {
ofono_error("Call Barring Set error %d", status);
cb(ril_error_failure(&error), cbd->data);
}
}
static void ril_call_barring_set(struct ofono_call_barring *b,
const char *lock, int enable, const char *passwd, int cls,
ofono_call_barring_set_cb_t cb, void *data)
{
struct ril_call_barring *bd = ofono_call_barring_get_data(b);
char cls_textual[RIL_MAX_SERVICE_LENGTH];
GRilIoRequest *req = grilio_request_new();
DBG("lock: %s, enable: %i, bearer class: %i", lock, enable, cls);
/*
* RIL modem does not support 7 as default bearer class. According to
* the 22.030 Annex C: When service code is not given it corresponds to
* "All tele and bearer services"
*/
if (cls == BEARER_CLASS_DEFAULT) {
cls = SERVICE_CLASS_NONE;
}
sprintf(cls_textual, "%d", cls);
/* See 3GPP 27.007 7.4 for parameter descriptions */
grilio_request_append_int32(req, RIL_SET_STRING_COUNT);
grilio_request_append_utf8(req, lock); /* Facility code */
grilio_request_append_utf8(req, enable ?
RIL_FACILITY_LOCK :
RIL_FACILITY_UNLOCK);
grilio_request_append_utf8(req, passwd);
grilio_request_append_utf8(req, cls_textual);
grilio_request_append_utf8(req, NULL); /* AID (not yet supported) */
ril_call_barring_submit_request(bd, req,
RIL_REQUEST_SET_FACILITY_LOCK,
ril_call_barring_set_cb, cb, data);
grilio_request_unref(req);
}
static void ril_call_barring_set_passwd_cb(GRilIoChannel *io, int status,
const void *data, guint len, void *user_data)
{
struct ofono_error error;
struct ril_call_barring_cbd *cbd = user_data;
ofono_call_barring_set_cb_t cb = cbd->cb.set;
if (status == RIL_E_SUCCESS) {
cb(ril_error_ok(&error), cbd->data);
} else {
ofono_error("Call Barring Set PW error %d", status);
cb(ril_error_failure(&error), cbd->data);
}
}
static void ril_call_barring_set_passwd(struct ofono_call_barring *b,
const char *lock, const char *old_passwd,
const char *new_passwd, ofono_call_barring_set_cb_t cb,
void *data)
{
struct ril_call_barring *bd = ofono_call_barring_get_data(b);
GRilIoRequest *req = grilio_request_new();
DBG("");
grilio_request_append_int32(req, RIL_SET_PW_STRING_COUNT);
grilio_request_append_utf8(req, lock); /* Facility code */
grilio_request_append_utf8(req, old_passwd);
grilio_request_append_utf8(req, new_passwd);
ril_call_barring_submit_request(bd, req,
RIL_REQUEST_CHANGE_BARRING_PASSWORD,
ril_call_barring_set_passwd_cb, cb, data);
grilio_request_unref(req);
}
static gboolean ril_call_barring_register(gpointer user_data)
{
struct ofono_call_barring *b = user_data;
struct ril_call_barring *bd = ril_call_barring_get_data(b);
GASSERT(bd->timer_id);
bd->timer_id = 0;
ofono_call_barring_register(b);
return FALSE;
}
static int ril_call_barring_probe(struct ofono_call_barring *b,
unsigned int vendor, void *data)
{
struct ril_modem *modem = data;
struct ril_call_barring *bd = g_new0(struct ril_call_barring, 1);
DBG("");
bd->q = grilio_queue_new(ril_modem_io(modem));
bd->timer_id = g_idle_add(ril_call_barring_register, b);
ofono_call_barring_set_data(b, bd);
return 0;
}
static void ril_call_barring_remove(struct ofono_call_barring *b)
{
struct ril_call_barring *bd = ril_call_barring_get_data(b);
DBG("");
ofono_call_barring_set_data(b, NULL);
if (bd->timer_id > 0) {
g_source_remove(bd->timer_id);
}
grilio_queue_cancel_all(bd->q, FALSE);
grilio_queue_unref(bd->q);
g_free(bd);
}
const struct ofono_call_barring_driver ril_call_barring_driver = {
.name = RILMODEM_DRIVER,
.probe = ril_call_barring_probe,
.remove = ril_call_barring_remove,
.query = ril_call_barring_query,
.set = ril_call_barring_set,
.set_passwd = ril_call_barring_set_passwd
};
/*
* Local Variables:
* mode: C
* c-basic-offset: 8
* indent-tabs-mode: t
* End:
*/

View File

@@ -0,0 +1,274 @@
/*
* oFono - Open Source Telephony - RIL-based devices
*
* Copyright (C) 2015-2017 Jolla Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "ril_plugin.h"
#include "ril_util.h"
#include "ril_log.h"
#include "common.h"
struct ril_call_forward {
GRilIoQueue *q;
guint timer_id;
};
enum ril_call_forward_action {
CF_ACTION_DISABLE,
CF_ACTION_ENABLE,
CF_ACTION_INTERROGATE,
CF_ACTION_REGISTRATION,
CF_ACTION_ERASURE
};
#define CF_TIME_DEFAULT (0)
struct ril_call_forward_cbd {
struct ril_call_forward *fd;
union _ofono_call_forward_cb {
ofono_call_forwarding_query_cb_t query;
ofono_call_forwarding_set_cb_t set;
gpointer ptr;
} cb;
gpointer data;
};
static inline struct ril_call_forward *ril_call_forward_get_data(
struct ofono_call_forwarding *cf)
{
return ofono_call_forwarding_get_data(cf);
}
static void ril_call_forward_cbd_free(gpointer cbd)
{
g_slice_free(struct ril_call_forward_cbd, cbd);
}
static struct ril_call_forward_cbd *ril_call_forward_cbd_new(void *cb,
void *data)
{
struct ril_call_forward_cbd *cbd;
cbd = g_slice_new0(struct ril_call_forward_cbd);
cbd->cb.ptr = cb;
cbd->data = data;
return cbd;
}
static GRilIoRequest *ril_call_forward_req(enum ril_call_forward_action action,
int type, int cls, const struct ofono_phone_number *number, int time)
{
GRilIoRequest *req = grilio_request_new();
/*
* Modem seems to respond with error to all requests
* made with bearer class BEARER_CLASS_DEFAULT.
*/
if (cls == BEARER_CLASS_DEFAULT) {
cls = SERVICE_CLASS_NONE;
}
grilio_request_append_int32(req, action);
grilio_request_append_int32(req, type);
grilio_request_append_int32(req, cls); /* Service class */
if (number) {
grilio_request_append_int32(req, number->type);
grilio_request_append_utf8(req, number->number);
} else {
grilio_request_append_int32(req, 0x81); /* TOA unknown */
grilio_request_append_utf8(req, NULL); /* No number */
}
grilio_request_append_int32(req, time);
return req;
}
static void ril_call_forward_set_cb(GRilIoChannel *io, int status,
const void *data, guint len, void *user_data)
{
struct ofono_error error;
struct ril_call_forward_cbd *cbd = user_data;
ofono_call_forwarding_set_cb_t cb = cbd->cb.set;
if (status == RIL_E_SUCCESS) {
cb(ril_error_ok(&error), cbd->data);
} else {
ofono_error("CF setting failed");
cb(ril_error_failure(&error), cbd->data);
}
}
static void ril_call_forward_set(struct ofono_call_forwarding *cf,
enum ril_call_forward_action cmd, int type, int cls,
const struct ofono_phone_number *number, int time,
ofono_call_forwarding_set_cb_t cb, void *data)
{
struct ril_call_forward *fd = ril_call_forward_get_data(cf);
GRilIoRequest *req = ril_call_forward_req(cmd, type, cls, number, time);
grilio_queue_send_request_full(fd->q, req, RIL_REQUEST_SET_CALL_FORWARD,
ril_call_forward_set_cb, ril_call_forward_cbd_free,
ril_call_forward_cbd_new(cb, data));
grilio_request_unref(req);
}
static void ril_call_forward_registration(struct ofono_call_forwarding *cf,
int type, int cls, const struct ofono_phone_number *number,
int time, ofono_call_forwarding_set_cb_t cb, void *data)
{
ofono_info("cf registration");
ril_call_forward_set(cf, CF_ACTION_REGISTRATION, type, cls,
number, time, cb, data);
}
static void ril_call_forward_erasure(struct ofono_call_forwarding *cf,
int type, int cls, ofono_call_forwarding_set_cb_t cb, void *data)
{
ofono_info("cf erasure");
ril_call_forward_set(cf, CF_ACTION_ERASURE, type, cls,
NULL, CF_TIME_DEFAULT, cb, data);
}
static void ril_call_forward_deactivate(struct ofono_call_forwarding *cf,
int type, int cls, ofono_call_forwarding_set_cb_t cb, void *data)
{
ofono_info("cf disable");
ril_call_forward_set(cf, CF_ACTION_DISABLE, type, cls,
NULL, CF_TIME_DEFAULT, cb, data);
}
static void ril_call_forward_activate(struct ofono_call_forwarding *cf,
int type, int cls, ofono_call_forwarding_set_cb_t cb, void *data)
{
ofono_info("cf enable");
ril_call_forward_set(cf, CF_ACTION_ENABLE, type, cls,
NULL, CF_TIME_DEFAULT, cb, data);
}
static void ril_call_forward_query_cb(GRilIoChannel *io, int status,
const void *data, guint len, void *user_data)
{
struct ofono_error error;
struct ril_call_forward_cbd *cbd = user_data;
ofono_call_forwarding_query_cb_t cb = cbd->cb.query;
if (status == RIL_E_SUCCESS) {
struct ofono_call_forwarding_condition *list = NULL;
GRilIoParser rilp;
int count = 0;
int i;
grilio_parser_init(&rilp, data, len);
grilio_parser_get_int32(&rilp, &count);
list = g_new0(struct ofono_call_forwarding_condition, count);
for (i = 0; i < count; i++) {
struct ofono_call_forwarding_condition *fw = list + i;
char *str;
grilio_parser_get_int32(&rilp, &fw->status);
grilio_parser_get_int32(&rilp, NULL);
grilio_parser_get_int32(&rilp, &fw->cls);
grilio_parser_get_int32(&rilp, &fw->phone_number.type);
str = grilio_parser_get_utf8(&rilp);
if (str) {
strncpy(fw->phone_number.number, str,
OFONO_MAX_PHONE_NUMBER_LENGTH);
fw->phone_number.number[
OFONO_MAX_PHONE_NUMBER_LENGTH] = 0;
g_free(str);
}
grilio_parser_get_int32(&rilp, &fw->time);
}
cb(ril_error_ok(&error), count, list, cbd->data);
g_free(list);
} else {
ofono_error("CF query failed");
cb(ril_error_failure(&error), 0, NULL, cbd->data);
}
}
static void ril_call_forward_query(struct ofono_call_forwarding *cf, int type,
int cls, ofono_call_forwarding_query_cb_t cb, void *data)
{
struct ril_call_forward *fd = ril_call_forward_get_data(cf);
GRilIoRequest *req = ril_call_forward_req(CF_ACTION_INTERROGATE,
type, cls, NULL, CF_TIME_DEFAULT);
ofono_info("cf query");
grilio_queue_send_request_full(fd->q, req,
RIL_REQUEST_QUERY_CALL_FORWARD_STATUS,
ril_call_forward_query_cb, ril_call_forward_cbd_free,
ril_call_forward_cbd_new(cb, data));
grilio_request_unref(req);
}
static gboolean ril_call_forward_register(gpointer user_data)
{
struct ofono_call_forwarding *cf = user_data;
struct ril_call_forward *fd = ril_call_forward_get_data(cf);
fd->timer_id = 0;
ofono_call_forwarding_register(cf);
return FALSE;
}
static int ril_call_forward_probe(struct ofono_call_forwarding *cf,
unsigned int vendor, void *data)
{
struct ril_modem *modem = data;
struct ril_call_forward *fd = g_try_new0(struct ril_call_forward, 1);
DBG("");
fd->q = grilio_queue_new(ril_modem_io(modem));
fd->timer_id = g_idle_add(ril_call_forward_register, cf);
ofono_call_forwarding_set_data(cf, fd);
return 0;
}
static void ril_call_forward_remove(struct ofono_call_forwarding *cf)
{
struct ril_call_forward *fd = ril_call_forward_get_data(cf);
DBG("");
ofono_call_forwarding_set_data(cf, NULL);
if (fd->timer_id) {
g_source_remove(fd->timer_id);
}
grilio_queue_cancel_all(fd->q, FALSE);
grilio_queue_unref(fd->q);
g_free(fd);
}
const struct ofono_call_forwarding_driver ril_call_forwarding_driver = {
.name = RILMODEM_DRIVER,
.probe = ril_call_forward_probe,
.remove = ril_call_forward_remove,
.erasure = ril_call_forward_erasure,
.deactivation = ril_call_forward_deactivate,
.query = ril_call_forward_query,
.registration = ril_call_forward_registration,
.activation = ril_call_forward_activate
};
/*
* Local Variables:
* mode: C
* c-basic-offset: 8
* indent-tabs-mode: t
* End:
*/

View File

@@ -0,0 +1,308 @@
/*
* oFono - Open Source Telephony - RIL-based devices
*
* Copyright (C) 2015-2017 Jolla Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "ril_plugin.h"
#include "ril_util.h"
#include "ril_log.h"
#include "common.h"
struct ril_call_settings {
GRilIoQueue *q;
guint timer_id;
};
struct ril_call_settings_cbd {
union _ofono_call_settings_cb {
ofono_call_settings_status_cb_t status;
ofono_call_settings_set_cb_t set;
ofono_call_settings_clir_cb_t clir;
gpointer ptr;
} cb;
gpointer data;
};
#define ril_call_settings_cbd_free g_free
static inline struct ril_call_settings *ril_call_settings_get_data(
struct ofono_call_settings *b)
{
return ofono_call_settings_get_data(b);
}
static struct ril_call_settings_cbd *ril_call_settings_cbd_new(void *cb,
void *data)
{
struct ril_call_settings_cbd *cbd;
cbd = g_new0(struct ril_call_settings_cbd, 1);
cbd->cb.ptr = cb;
cbd->data = data;
return cbd;
}
static inline void ril_call_settings_submit_req(struct ril_call_settings *sd,
GRilIoRequest* req, guint code, GRilIoChannelResponseFunc response,
void *cb, void *data)
{
grilio_queue_send_request_full(sd->q, req, code, response,
ril_call_settings_cbd_free,
ril_call_settings_cbd_new(cb, data));
}
static void ril_call_settings_clip_query_cb(GRilIoChannel *io, int status,
const void *data, guint len, void *user_data)
{
struct ofono_error error;
struct ril_call_settings_cbd *cbd = user_data;
ofono_call_settings_status_cb_t cb = cbd->cb.status;
if (status == RIL_E_SUCCESS) {
GRilIoParser rilp;
int res = 0;
/* data length of the response */
grilio_parser_init(&rilp, data, len);
if (grilio_parser_get_int32(&rilp, &res) && res > 0) {
grilio_parser_get_int32(&rilp, &res);
}
cb(ril_error_ok(&error), res, cbd->data);
} else {
cb(ril_error_failure(&error), -1, cbd->data);
}
}
static void ril_call_settings_set_cb(GRilIoChannel *io, int status,
const void *data, guint len, void *user_data)
{
struct ofono_error error;
struct ril_call_settings_cbd *cbd = user_data;
ofono_call_settings_set_cb_t cb = cbd->cb.set;
if (status == RIL_E_SUCCESS) {
cb(ril_error_ok(&error), cbd->data);
} else {
cb(ril_error_failure(&error), cbd->data);
}
}
static void ril_call_settings_cw_set(struct ofono_call_settings *cs, int mode,
int cls, ofono_call_settings_set_cb_t cb, void *data)
{
struct ril_call_settings *sd = ril_call_settings_get_data(cs);
GRilIoRequest *req = grilio_request_sized_new(12);
grilio_request_append_int32(req, 2); /* Number of params */
grilio_request_append_int32(req, mode); /* on/off */
/* Modem seems to respond with error to all queries
* or settings made with bearer class
* BEARER_CLASS_DEFAULT. Design decision: If given
* class is BEARER_CLASS_DEFAULT let's map it to
* SERVICE_CLASS_VOICE effectively making it the
* default bearer. This in line with API which is
* contains only voice anyways.
*/
if (cls == BEARER_CLASS_DEFAULT) {
cls = BEARER_CLASS_VOICE;
}
grilio_request_append_int32(req, cls); /* Service class */
ril_call_settings_submit_req(sd, req, RIL_REQUEST_SET_CALL_WAITING,
ril_call_settings_set_cb, cb, data);
grilio_request_unref(req);
}
static void ril_call_settings_cw_query_cb(GRilIoChannel *io, int status,
const void *data, guint len, void *user_data)
{
struct ofono_error error;
struct ril_call_settings_cbd *cbd = user_data;
ofono_call_settings_status_cb_t cb = cbd->cb.status;
if (status == RIL_E_SUCCESS) {
GRilIoParser rilp;
int res = 0;
int sv = 0;
grilio_parser_init(&rilp, data, len);
/* first value in int[] is len so let's skip that */
grilio_parser_get_int32(&rilp, NULL);
/* status of call waiting service, disabled is returned only if
* service is not active for any service class */
grilio_parser_get_int32(&rilp, &res);
DBG("CW enabled/disabled: %d", res);
if (res > 0) {
/* services for which call waiting is enabled,
27.007 7.12 */
grilio_parser_get_int32(&rilp, &sv);
DBG("CW enabled for: %d", sv);
}
cb(ril_error_ok(&error), sv, cbd->data);
} else {
cb(ril_error_failure(&error), -1, cbd->data);
}
}
static void ril_call_settings_cw_query(struct ofono_call_settings *cs, int cls,
ofono_call_settings_status_cb_t cb, void *data)
{
struct ril_call_settings *sd = ril_call_settings_get_data(cs);
GRilIoRequest *req = grilio_request_sized_new(8);
grilio_request_append_int32(req, 1); /* Number of params */
/*
* RILD expects service class to be 0 as certain carriers can reject
* the query with specific service class
*/
grilio_request_append_int32(req, 0);
ril_call_settings_submit_req(sd, req, RIL_REQUEST_QUERY_CALL_WAITING,
ril_call_settings_cw_query_cb, cb, data);
grilio_request_unref(req);
}
static void ril_call_settings_clip_query(struct ofono_call_settings *cs,
ofono_call_settings_status_cb_t cb, void *data)
{
struct ril_call_settings *sd = ril_call_settings_get_data(cs);
ril_call_settings_submit_req(sd, NULL, RIL_REQUEST_QUERY_CLIP,
ril_call_settings_clip_query_cb, cb, data);
}
static void ril_call_settings_clir_cb(GRilIoChannel *io, int status,
const void *data, guint len, void *user_data)
{
struct ofono_error error;
struct ril_call_settings_cbd *cbd = user_data;
ofono_call_settings_clir_cb_t cb = cbd->cb.clir;
if (status == RIL_E_SUCCESS) {
GRilIoParser rilp;
int override = -1, network = -1;
grilio_parser_init(&rilp, data, len);
/*first value in int[] is len so let's skip that*/
grilio_parser_get_int32(&rilp, NULL);
/* Set HideCallerId property from network */
grilio_parser_get_int32(&rilp, &override);
/* CallingLineRestriction indicates the state of
the CLIR supplementary service in the network */
grilio_parser_get_int32(&rilp, &network);
cb(ril_error_ok(&error), override, network, cbd->data);
} else {
cb(ril_error_failure(&error), -1, -1, cbd->data);
}
}
static void ril_call_settings_clir_query(struct ofono_call_settings *cs,
ofono_call_settings_clir_cb_t cb, void *data)
{
struct ril_call_settings *sd = ril_call_settings_get_data(cs);
ril_call_settings_submit_req(sd, NULL, RIL_REQUEST_GET_CLIR,
ril_call_settings_clir_cb, cb, data);
}
static void ril_call_settings_clir_set(struct ofono_call_settings *cs,
int mode, ofono_call_settings_set_cb_t cb, void *data)
{
struct ril_call_settings *sd = ril_call_settings_get_data(cs);
GRilIoRequest *req = grilio_request_sized_new(8);
grilio_request_append_int32(req, 1); /* Number of params */
grilio_request_append_int32(req, mode); /* for outgoing calls */
ril_call_settings_submit_req(sd, req, RIL_REQUEST_SET_CLIR,
ril_call_settings_set_cb, cb, data);
grilio_request_unref(req);
}
static gboolean ril_call_settings_register(gpointer user_data)
{
struct ofono_call_settings *cs = user_data;
struct ril_call_settings *sd = ril_call_settings_get_data(cs);
DBG("");
GASSERT(sd->timer_id);
sd->timer_id = 0;
ofono_call_settings_register(cs);
/* Single-shot */
return FALSE;
}
static int ril_call_settings_probe(struct ofono_call_settings *cs,
unsigned int vendor, void *data)
{
struct ril_modem *modem = data;
struct ril_call_settings *sd = g_try_new0(struct ril_call_settings, 1);
DBG("");
sd->q = grilio_queue_new(ril_modem_io(modem));
sd->timer_id = g_idle_add(ril_call_settings_register, cs);
ofono_call_settings_set_data(cs, sd);
return 0;
}
static void ril_call_settings_remove(struct ofono_call_settings *cs)
{
struct ril_call_settings *sd = ril_call_settings_get_data(cs);
DBG("");
ofono_call_settings_set_data(cs, NULL);
if (sd->timer_id > 0) {
g_source_remove(sd->timer_id);
}
grilio_queue_cancel_all(sd->q, FALSE);
grilio_queue_unref(sd->q);
g_free(sd);
}
const struct ofono_call_settings_driver ril_call_settings_driver = {
.name = RILMODEM_DRIVER,
.probe = ril_call_settings_probe,
.remove = ril_call_settings_remove,
.clip_query = ril_call_settings_clip_query,
.cw_query = ril_call_settings_cw_query,
.cw_set = ril_call_settings_cw_set,
.clir_query = ril_call_settings_clir_query,
.clir_set = ril_call_settings_clir_set
/*
* Not supported in RIL API
* .colp_query = ril_call_settings_colp_query,
* .colr_query = ril_call_settings_colr_query
*/
};
/*
* Local Variables:
* mode: C
* c-basic-offset: 8
* indent-tabs-mode: t
* End:
*/

View File

@@ -0,0 +1,150 @@
/*
* oFono - Open Source Telephony - RIL-based devices
*
* Copyright (C) 2015-2017 Jolla Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "ril_plugin.h"
#include "ril_util.h"
#include "ril_log.h"
struct ril_call_volume {
struct ofono_call_volume *v;
GRilIoQueue *q;
guint timer_id;
};
struct ril_call_volume_req {
ofono_call_volume_cb_t cb;
gpointer data;
};
static inline struct ril_call_volume *ril_call_volume_get_data(
struct ofono_call_volume *v)
{
return ofono_call_volume_get_data(v);
}
static void ril_call_volume_mute_cb(GRilIoChannel *io, int status,
const void *data, guint len, void *user_data)
{
struct ofono_error error;
struct ril_call_volume_req *cbd = user_data;
ofono_call_volume_cb_t cb = cbd->cb;
if (status == RIL_E_SUCCESS) {
cb(ril_error_ok(&error), cbd->data);
} else {
ofono_error("Could not set the ril mute state");
cb(ril_error_failure(&error), cbd->data);
}
}
static void ril_call_volume_mute(struct ofono_call_volume *v, int muted,
ofono_call_volume_cb_t cb, void *data)
{
struct ril_call_volume *vd = ril_call_volume_get_data(v);
struct ril_call_volume_req *cbd;
GRilIoRequest *req = grilio_request_sized_new(8);
cbd = g_new(struct ril_call_volume_req, 1);
cbd->cb = cb;
cbd->data = data;
DBG("%d", muted);
grilio_request_append_int32(req, 1);
grilio_request_append_int32(req, muted);
grilio_queue_send_request_full(vd->q, req, RIL_REQUEST_SET_MUTE,
ril_call_volume_mute_cb, g_free, cbd);
grilio_request_unref(req);
}
static void ril_call_volume_query_mute_cb(GRilIoChannel *io, int status,
const void *data, guint len, void *user_data)
{
struct ril_call_volume *vd = user_data;
if (status == RIL_E_SUCCESS) {
int muted = 0;
GRilIoParser rilp;
grilio_parser_init(&rilp, data, len);
grilio_parser_get_int32(&rilp, NULL); /* Array length */
grilio_parser_get_int32(&rilp, &muted);
DBG("{%d}", muted);
ofono_call_volume_set_muted(vd->v, muted);
} else {
ofono_error("Could not retrive the ril mute state");
}
}
static gboolean ril_call_volume_register(gpointer user_data)
{
struct ril_call_volume *vd = user_data;
DBG("");
GASSERT(vd->timer_id);
vd->timer_id = 0;
ofono_call_volume_register(vd->v);
/* Probe the mute state */
grilio_queue_send_request_full(vd->q, NULL,
RIL_REQUEST_GET_MUTE, ril_call_volume_query_mute_cb, NULL, vd);
/* This makes the timeout a single-shot */
return FALSE;
}
static int ril_call_volume_probe(struct ofono_call_volume *v,
unsigned int vendor, void *data)
{
struct ril_modem *modem = data;
struct ril_call_volume *vd = g_new0(struct ril_call_volume, 1);
DBG("");
vd->v = v;
vd->q = grilio_queue_new(ril_modem_io(modem));
vd->timer_id = g_idle_add(ril_call_volume_register, vd);
ofono_call_volume_set_data(v, vd);
return 0;
}
static void ril_call_volume_remove(struct ofono_call_volume *v)
{
struct ril_call_volume *vd = ril_call_volume_get_data(v);
DBG("");
ofono_call_volume_set_data(v, NULL);
if (vd->timer_id) {
g_source_remove(vd->timer_id);
}
grilio_queue_cancel_all(vd->q, FALSE);
grilio_queue_unref(vd->q);
g_free(vd);
}
const struct ofono_call_volume_driver ril_call_volume_driver = {
.name = RILMODEM_DRIVER,
.probe = ril_call_volume_probe,
.remove = ril_call_volume_remove,
.mute = ril_call_volume_mute,
};
/*
* Local Variables:
* mode: C
* c-basic-offset: 8
* indent-tabs-mode: t
* End:
*/

230
ofono/drivers/ril/ril_cbs.c Normal file
View File

@@ -0,0 +1,230 @@
/*
* oFono - Open Source Telephony - RIL-based devices
*
* Copyright (C) 2015-2017 Jolla Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "ril_plugin.h"
#include "ril_util.h"
#include "ril_log.h"
#include <gutil_strv.h>
struct ril_cbs {
struct ofono_cbs *cbs;
GRilIoChannel *io;
GRilIoQueue *q;
char *log_prefix;
gulong event_id;
};
struct ril_cbs_cbd {
struct ril_cbs *cd;
ofono_cbs_set_cb_t cb;
gpointer data;
};
#define RIL_CBS_CHECK_RETRY_MS 1000
#define RIL_CBS_CHECK_RETRY_COUNT 30
#define DBG_(cd,fmt,args...) DBG("%s" fmt, (cd)->log_prefix, ##args)
#define ril_cbs_cbd_free g_free
static struct ril_cbs_cbd *ril_cbs_cbd_new(struct ril_cbs *cd,
ofono_cbs_set_cb_t cb, void *data)
{
struct ril_cbs_cbd *cbd = g_new(struct ril_cbs_cbd, 1);
cbd->cd = cd;
cbd->cb = cb;
cbd->data = data;
return cbd;
}
static void ril_cbs_request_activation(struct ril_cbs *cd,
gboolean activate, GRilIoChannelResponseFunc response,
GDestroyNotify destroy, void* user_data)
{
GRilIoRequest* req = grilio_request_sized_new(8);
grilio_request_append_int32(req, 1);
grilio_request_append_int32(req, activate ? 0 :1);
DBG_(cd, "%sactivating CB", activate ? "" : "de");
grilio_queue_send_request_full(cd->q, req,
RIL_REQUEST_GSM_SMS_BROADCAST_ACTIVATION,
response, destroy, user_data);
grilio_request_unref(req);
}
static void ril_cbs_set_config(struct ril_cbs *cd, const char *topics,
GRilIoChannelResponseFunc response,
GDestroyNotify destroy, void* user_data)
{
char **list = topics ? g_strsplit(topics, ",", 0) : NULL;
int i, n = gutil_strv_length(list);
GRilIoRequest* req = grilio_request_new();
grilio_request_append_int32(req, n);
for (i = 0; i < n; i++) {
const char *entry = list[i];
const char *delim = strchr(entry, '-');
int from, to;
if (delim) {
char **range = g_strsplit(topics, "-", 0);
from = atoi(range[0]);
to = atoi(range[1]);
g_strfreev(range);
} else {
from = to = atoi(entry);
}
grilio_request_append_int32(req, from);
grilio_request_append_int32(req, to);
grilio_request_append_int32(req, 0);
grilio_request_append_int32(req, 0xff);
grilio_request_append_int32(req, 1);
}
DBG_(cd, "configuring CB");
grilio_queue_send_request_full(cd->q, req,
RIL_REQUEST_GSM_SET_BROADCAST_SMS_CONFIG,
response, destroy, user_data);
grilio_request_unref(req);
g_strfreev(list);
}
static void ril_cbs_cb(GRilIoChannel *io, int ril_status,
const void *data, guint len, void *user_data)
{
struct ril_cbs_cbd *cbd = user_data;
if (cbd->cb) {
struct ofono_error error;
if (ril_status == RIL_E_SUCCESS) {
cbd->cb(ril_error_ok(&error), cbd->data);
} else {
cbd->cb(ril_error_failure(&error), cbd->data);
}
}
}
static void ril_cbs_set_topics(struct ofono_cbs *cbs, const char *topics,
ofono_cbs_set_cb_t cb, void *data)
{
struct ril_cbs *cd = ofono_cbs_get_data(cbs);
DBG_(cd, "%s", topics);
ril_cbs_set_config(cd, topics, ril_cbs_cb, ril_cbs_cbd_free,
ril_cbs_cbd_new(cd, cb, data));
}
static void ril_cbs_clear_topics(struct ofono_cbs *cbs,
ofono_cbs_set_cb_t cb, void *data)
{
struct ril_cbs *cd = ofono_cbs_get_data(cbs);
DBG_(cd, "");
ril_cbs_request_activation(cd, FALSE, ril_cbs_cb, ril_cbs_cbd_free,
ril_cbs_cbd_new(cd, cb, data));
}
static void ril_cbs_notify(GRilIoChannel *io, guint code,
const void *data, guint len, void *user_data)
{
struct ril_cbs *cd = user_data;
GASSERT(code == RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS);
DBG_(cd, "%u bytes", len);
ofono_cbs_notify(cd->cbs, data, len);
}
static void ril_cbs_probe_done_cb(GRilIoChannel *io, int status,
const void *data, guint len, void *user_data)
{
struct ril_cbs *cd = user_data;
if (status == RIL_E_SUCCESS) {
DBG_(cd, "registering for CB");
cd->event_id = grilio_channel_add_unsol_event_handler(cd->io,
ril_cbs_notify, RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS,
cd);
ofono_cbs_register(cd->cbs);
} else {
DBG_(cd, "failed to query CB config");
ofono_cbs_remove(cd->cbs);
}
}
static int ril_cbs_probe(struct ofono_cbs *cbs, unsigned int vendor,
void *data)
{
struct ril_modem *modem = data;
struct ril_cbs *cd = g_try_new0(struct ril_cbs, 1);
GRilIoRequest* req = grilio_request_new();
ofono_cbs_set_data(cbs, cd);
cd->log_prefix = (modem->log_prefix && modem->log_prefix[0]) ?
g_strconcat(modem->log_prefix, " ", NULL) : g_strdup("");
cd->cbs = cbs;
DBG_(cd, "");
cd->io = grilio_channel_ref(ril_modem_io(modem));
cd->q = grilio_queue_new(cd->io);
/*
* RIL_REQUEST_GSM_GET_BROADCAST_SMS_CONFIG often fails at startup
* especially if other RIL requests are running in parallel. We may
* have to retry a few times. Also, make it blocking in order to
* improve the chance of success.
*/
grilio_request_set_retry(req, RIL_CBS_CHECK_RETRY_MS,
RIL_CBS_CHECK_RETRY_COUNT);
grilio_request_set_blocking(req, TRUE);
grilio_queue_send_request_full(cd->q, req,
RIL_REQUEST_GSM_GET_BROADCAST_SMS_CONFIG,
ril_cbs_probe_done_cb, NULL, cd);
grilio_request_unref(req);
return 0;
}
static void ril_cbs_remove(struct ofono_cbs *cbs)
{
struct ril_cbs *cd = ofono_cbs_get_data(cbs);
DBG_(cd, "");
ofono_cbs_set_data(cbs, NULL);
grilio_channel_remove_handler(cd->io, cd->event_id);
grilio_channel_unref(cd->io);
grilio_queue_cancel_all(cd->q, FALSE);
grilio_queue_unref(cd->q);
g_free(cd->log_prefix);
g_free(cd);
}
const struct ofono_cbs_driver ril_cbs_driver = {
.name = RILMODEM_DRIVER,
.probe = ril_cbs_probe,
.remove = ril_cbs_remove,
.set_topics = ril_cbs_set_topics,
.clear_topics = ril_cbs_clear_topics
};
/*
* Local Variables:
* mode: C
* c-basic-offset: 8
* indent-tabs-mode: t
* End:
*/

View File

@@ -0,0 +1,543 @@
/*
* oFono - Open Source Telephony - RIL-based devices
*
* Copyright (C) 2016-2018 Jolla Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "ril_cell_info.h"
#include "ril_sim_card.h"
#include "ril_radio.h"
#include "ril_util.h"
#include "ril_log.h"
#include <grilio_channel.h>
#include <grilio_request.h>
#include <grilio_parser.h>
#include <gutil_misc.h>
#define DISPLAY_ON_UPDATE_RATE (1000) /* 1 sec */
#define DISPLAY_OFF_UPDATE_RATE (60000) /* 1 min */
#define MAX_RETRIES (5)
typedef GObjectClass RilCellInfoClass;
typedef struct ril_cell_info RilCellInfo;
struct ril_cell_info {
GObject object;
struct sailfish_cell_info info;
GRilIoChannel *io;
MceDisplay *display;
struct ril_radio *radio;
struct ril_sim_card *sim_card;
gulong display_state_event_id;
gulong radio_state_event_id;
gulong sim_status_event_id;
gboolean sim_card_ready;
char *log_prefix;
gulong event_id;
guint query_id;
guint set_rate_id;
};
enum ril_cell_info_signal {
SIGNAL_CELLS_CHANGED,
SIGNAL_COUNT
};
#define SIGNAL_CELLS_CHANGED_NAME "ril-cell-info-cells-changed"
static guint ril_cell_info_signals[SIGNAL_COUNT] = { 0 };
G_DEFINE_TYPE(RilCellInfo, ril_cell_info, G_TYPE_OBJECT)
#define RIL_CELL_INFO_TYPE (ril_cell_info_get_type())
#define RIL_CELL_INFO(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),\
RIL_CELL_INFO_TYPE, RilCellInfo))
#define DBG_(self,fmt,args...) DBG("%s" fmt, (self)->log_prefix, ##args)
static inline void ril_cell_free(struct sailfish_cell *cell)
{
g_slice_free(struct sailfish_cell, cell);
}
static void ril_cell_free1(gpointer cell)
{
ril_cell_free(cell);
}
static gboolean ril_cell_info_list_identical(GSList *l1, GSList *l2)
{
while (l1 && l2) {
if (memcmp(l1->data, l2->data, sizeof(struct sailfish_cell))) {
return FALSE;
}
l1 = l1->next;
l2 = l2->next;
}
return !l1 && !l2;
}
static void ril_cell_info_update_cells(struct ril_cell_info *self, GSList *l)
{
if (!ril_cell_info_list_identical(self->info.cells, l)) {
g_slist_free_full(self->info.cells, ril_cell_free1);
self->info.cells = l;
g_signal_emit(self, ril_cell_info_signals
[SIGNAL_CELLS_CHANGED], 0);
} else {
g_slist_free_full(l, ril_cell_free1);
}
}
static struct sailfish_cell *ril_cell_info_parse_cell_gsm(GRilIoParser *rilp,
guint version, gboolean registered)
{
struct sailfish_cell *cell = g_slice_new0(struct sailfish_cell);
struct sailfish_cell_info_gsm *gsm = &cell->info.gsm;
/* Optional RIL_CellIdentityGsm_v12 part */
gsm->arfcn = INT_MAX;
gsm->bsic = INT_MAX;
/* Optional RIL_GSM_SignalStrength_v12 part */
gsm->timingAdvance = INT_MAX;
/* RIL_CellIdentityGsm */
if (grilio_parser_get_int32(rilp, &gsm->mcc) &&
grilio_parser_get_int32(rilp, &gsm->mnc) &&
grilio_parser_get_int32(rilp, &gsm->lac) &&
grilio_parser_get_int32(rilp, &gsm->cid) &&
(version < 12 || /* RIL_CellIdentityGsm_v12 part */
(grilio_parser_get_int32(rilp, &gsm->arfcn) &&
grilio_parser_get_int32(rilp, &gsm->bsic))) &&
/* RIL_GW_SignalStrength */
grilio_parser_get_int32(rilp, &gsm->signalStrength) &&
grilio_parser_get_int32(rilp, &gsm->bitErrorRate) &&
(version < 12 || /* RIL_GSM_SignalStrength_v12 part */
grilio_parser_get_int32(rilp, &gsm->timingAdvance))) {
DBG("[gsm] reg=%d,mcc=%d,mnc=%d,lac=%d,cid=%d,arfcn=%d,"
"bsic=%d,strength=%d,err=%d,t=%d", registered,
gsm->mcc, gsm->mnc, gsm->lac, gsm->cid, gsm->arfcn,
gsm->bsic, gsm->signalStrength, gsm->bitErrorRate,
gsm->timingAdvance);
cell->type = SAILFISH_CELL_TYPE_GSM;
cell->registered = registered;
return cell;
}
ofono_error("failed to parse GSM cell info");
ril_cell_free(cell);
return NULL;
}
static struct sailfish_cell *ril_cell_info_parse_cell_wcdma(GRilIoParser *rilp,
guint version, gboolean registered)
{
struct sailfish_cell *cell = g_slice_new0(struct sailfish_cell);
struct sailfish_cell_info_wcdma *wcdma = &cell->info.wcdma;
/* Optional RIL_CellIdentityWcdma_v12 part */
wcdma->uarfcn = INT_MAX;
if (grilio_parser_get_int32(rilp, &wcdma->mcc) &&
grilio_parser_get_int32(rilp, &wcdma->mnc) &&
grilio_parser_get_int32(rilp, &wcdma->lac) &&
grilio_parser_get_int32(rilp, &wcdma->cid) &&
grilio_parser_get_int32(rilp, &wcdma->psc) &&
(version < 12 || /* RIL_CellIdentityWcdma_v12 part */
grilio_parser_get_int32(rilp, &wcdma->uarfcn)) &&
grilio_parser_get_int32(rilp, &wcdma->signalStrength) &&
grilio_parser_get_int32(rilp, &wcdma->bitErrorRate)) {
DBG("[wcdma] reg=%d,mcc=%d,mnc=%d,lac=%d,cid=%d,psc=%d,"
"strength=%d,err=%d", registered, wcdma->mcc,
wcdma->mnc, wcdma->lac, wcdma->cid, wcdma->psc,
wcdma->signalStrength, wcdma->bitErrorRate);
cell->type = SAILFISH_CELL_TYPE_WCDMA;
cell->registered = registered;
return cell;
}
ofono_error("failed to parse WCDMA cell info");
ril_cell_free(cell);
return NULL;
}
static struct sailfish_cell *ril_cell_info_parse_cell_lte(GRilIoParser *rilp,
guint version, gboolean registered)
{
struct sailfish_cell *cell = g_slice_new0(struct sailfish_cell);
struct sailfish_cell_info_lte *lte = &cell->info.lte;
/* Optional RIL_CellIdentityLte_v12 part */
lte->earfcn = INT_MAX;
if (grilio_parser_get_int32(rilp, &lte->mcc) &&
grilio_parser_get_int32(rilp, &lte->mnc) &&
grilio_parser_get_int32(rilp, &lte->ci) &&
grilio_parser_get_int32(rilp, &lte->pci) &&
grilio_parser_get_int32(rilp, &lte->tac) &&
(version < 12 || /* RIL_CellIdentityLte_v12 part */
grilio_parser_get_int32(rilp, &lte->earfcn)) &&
grilio_parser_get_int32(rilp, &lte->signalStrength) &&
grilio_parser_get_int32(rilp, &lte->rsrp) &&
grilio_parser_get_int32(rilp, &lte->rsrq) &&
grilio_parser_get_int32(rilp, &lte->rssnr) &&
grilio_parser_get_int32(rilp, &lte->cqi) &&
grilio_parser_get_int32(rilp, &lte->timingAdvance)) {
DBG("[lte] reg=%d,mcc=%d,mnc=%d,ci=%d,pci=%d,tac=%d,"
"strength=%d,rsrp=%d,rsrq=%d,rssnr=%d,cqi=%d,"
"t=0x%x", registered, lte->mcc, lte->mnc, lte->ci,
lte->pci, lte->tac, lte->signalStrength, lte->rsrp,
lte->rsrq, lte->rssnr, lte->cqi, lte->timingAdvance);
cell->type = SAILFISH_CELL_TYPE_LTE;
cell->registered = registered;
return cell;
}
ofono_error("failed to parse LTE cell info");
ril_cell_free(cell);
return NULL;
}
static gboolean ril_cell_info_parse_cell(GRilIoParser *rilp, guint v,
struct sailfish_cell **cell_ptr)
{
int type, reg;
if (grilio_parser_get_int32(rilp, &type) &&
grilio_parser_get_int32(rilp, &reg) &&
/* Skip timestamp */
grilio_parser_get_int32_array(rilp, NULL, 3)) {
int skip = 0;
struct sailfish_cell *cell = NULL;
/* Normalize the boolean value */
reg = (reg != FALSE);
switch (type) {
case RIL_CELL_INFO_TYPE_GSM:
cell = ril_cell_info_parse_cell_gsm(rilp, v, reg);
break;
case RIL_CELL_INFO_TYPE_WCDMA:
cell = ril_cell_info_parse_cell_wcdma(rilp, v, reg);
break;
case RIL_CELL_INFO_TYPE_LTE:
cell = ril_cell_info_parse_cell_lte(rilp, v, reg);
break;
case RIL_CELL_INFO_TYPE_CDMA:
skip = 10;
break;
case RIL_CELL_INFO_TYPE_TD_SCDMA:
skip = 6;
break;
default:
skip = 0;
break;
}
if (cell) {
*cell_ptr = cell;
return TRUE;
}
if (skip && grilio_parser_get_int32_array(rilp, NULL, skip)) {
*cell_ptr = NULL;
return TRUE;
}
}
*cell_ptr = NULL;
return FALSE;
}
static GSList *ril_cell_info_parse_list(guint v, const void *data, guint len)
{
GSList *l = NULL;
GRilIoParser rilp;
int i, n;
grilio_parser_init(&rilp, data, len);
if (grilio_parser_get_int32(&rilp, &n) && n > 0) {
struct sailfish_cell *c;
DBG("%d cell(s):", n);
for (i=0; i<n && ril_cell_info_parse_cell(&rilp, v, &c); i++) {
if (c) {
l = g_slist_insert_sorted(l, c,
sailfish_cell_compare_func);
}
}
}
GASSERT(grilio_parser_at_end(&rilp));
return l;
}
static void ril_cell_info_list_changed_cb(GRilIoChannel *io, guint code,
const void *data, guint len, void *user_data)
{
struct ril_cell_info *self = RIL_CELL_INFO(user_data);
DBG_(self, "");
ril_cell_info_update_cells(self, ril_cell_info_parse_list
(io->ril_version, data, len));
}
static void ril_cell_info_list_cb(GRilIoChannel *io, int status,
const void *data, guint len, void *user_data)
{
struct ril_cell_info *self = RIL_CELL_INFO(user_data);
DBG_(self, "");
GASSERT(self->query_id);
self->query_id = 0;
ril_cell_info_update_cells(self, (status == RIL_E_SUCCESS) ?
ril_cell_info_parse_list(io->ril_version, data, len) : NULL);
}
static void ril_cell_info_set_rate_cb(GRilIoChannel *io, int status,
const void *data, guint len, void *user_data)
{
struct ril_cell_info *self = RIL_CELL_INFO(user_data);
DBG_(self, "");
GASSERT(self->set_rate_id);
self->set_rate_id = 0;
}
static void ril_cell_info_query(struct ril_cell_info *self)
{
GRilIoRequest *req = grilio_request_new();
grilio_request_set_retry(req, RIL_RETRY_MS, MAX_RETRIES);
grilio_channel_cancel_request(self->io, self->query_id, FALSE);
self->query_id = grilio_channel_send_request_full(self->io, req,
RIL_REQUEST_GET_CELL_INFO_LIST, ril_cell_info_list_cb,
NULL, self);
grilio_request_unref(req);
}
static void ril_cell_info_set_rate(struct ril_cell_info *self, int ms)
{
GRilIoRequest *req = grilio_request_sized_new(8);
grilio_request_append_int32(req, 1);
grilio_request_append_int32(req, ms);
grilio_request_set_retry(req, RIL_RETRY_MS, MAX_RETRIES);
grilio_channel_cancel_request(self->io, self->set_rate_id, FALSE);
self->set_rate_id = grilio_channel_send_request_full(self->io, req,
RIL_REQUEST_SET_UNSOL_CELL_INFO_LIST_RATE,
ril_cell_info_set_rate_cb, NULL, self);
grilio_request_unref(req);
}
static void ril_cell_info_update_rate(struct ril_cell_info *self)
{
if (self->sim_card_ready) {
ril_cell_info_set_rate(self,
(self->display->state == MCE_DISPLAY_STATE_OFF) ?
DISPLAY_OFF_UPDATE_RATE : DISPLAY_ON_UPDATE_RATE);
}
}
static void ril_cell_info_display_state_cb(MceDisplay *display, void *arg)
{
ril_cell_info_update_rate(RIL_CELL_INFO(arg));
}
static void ril_cell_info_refresh(struct ril_cell_info *self)
{
/* RIL_REQUEST_GET_CELL_INFO_LIST fails without SIM card */
if (self->radio->state == RADIO_STATE_ON && self->sim_card_ready) {
ril_cell_info_query(self);
} else {
ril_cell_info_update_cells(self, NULL);
}
}
static void ril_cell_info_radio_state_cb(struct ril_radio *radio, void *arg)
{
struct ril_cell_info *self = RIL_CELL_INFO(arg);
DBG_(self, "%s", ril_radio_state_to_string(radio->state));
ril_cell_info_refresh(self);
}
static void ril_cell_info_sim_status_cb(struct ril_sim_card *sim, void *arg)
{
struct ril_cell_info *self = RIL_CELL_INFO(arg);
self->sim_card_ready = ril_sim_card_ready(sim);
DBG_(self, "%sready", self->sim_card_ready ? "" : "not ");
ril_cell_info_refresh(self);
ril_cell_info_update_rate(self);
}
/* sailfish_cell_info interface callbacks */
struct ril_cell_info_signal_data {
sailfish_cell_info_cb_t cb;
void *arg;
};
static inline struct ril_cell_info *ril_cell_info_cast
(struct sailfish_cell_info *info)
{
return G_CAST(info, struct ril_cell_info, info);
}
static void ril_cell_info_ref_proc(struct sailfish_cell_info *info)
{
g_object_ref(ril_cell_info_cast(info));
}
static void ril_cell_info_unref_proc(struct sailfish_cell_info *info)
{
g_object_unref(ril_cell_info_cast(info));
}
static void ril_cell_info_cells_changed_cb(struct ril_cell_info *self,
void *user_data)
{
struct ril_cell_info_signal_data *data = user_data;
data->cb(&self->info, data->arg);
}
static void ril_cell_info_cells_disconnect_notify(gpointer data,
GClosure *closure)
{
g_slice_free1(sizeof(struct ril_cell_info_signal_data), data);
}
static gulong ril_cell_info_add_cells_changed_handler_proc
(struct sailfish_cell_info *info,
sailfish_cell_info_cb_t cb, void *arg)
{
if (cb) {
struct ril_cell_info_signal_data *data =
g_slice_new(struct ril_cell_info_signal_data);
data->cb = cb;
data->arg = arg;
return g_signal_connect_data(ril_cell_info_cast(info),
SIGNAL_CELLS_CHANGED_NAME,
G_CALLBACK(ril_cell_info_cells_changed_cb),
data, ril_cell_info_cells_disconnect_notify,
G_CONNECT_AFTER);
} else {
return 0;
}
}
static void ril_cell_info_remove_handler_proc(struct sailfish_cell_info *info,
gulong id)
{
if (G_LIKELY(id)) {
g_signal_handler_disconnect(ril_cell_info_cast(info), id);
}
}
struct sailfish_cell_info *ril_cell_info_new(GRilIoChannel *io,
const char *log_prefix, MceDisplay *display,
struct ril_radio *radio, struct ril_sim_card *sim_card)
{
static const struct sailfish_cell_info_proc ril_cell_info_proc = {
ril_cell_info_ref_proc,
ril_cell_info_unref_proc,
ril_cell_info_add_cells_changed_handler_proc,
ril_cell_info_remove_handler_proc
};
struct ril_cell_info *self = g_object_new(RIL_CELL_INFO_TYPE, 0);
self->info.proc = &ril_cell_info_proc;
self->io = grilio_channel_ref(io);
self->display = mce_display_ref(display);
self->radio = ril_radio_ref(radio);
self->sim_card = ril_sim_card_ref(sim_card);
self->log_prefix = (log_prefix && log_prefix[0]) ?
g_strconcat(log_prefix, " ", NULL) : g_strdup("");
DBG_(self, "");
self->event_id = grilio_channel_add_unsol_event_handler(self->io,
ril_cell_info_list_changed_cb, RIL_UNSOL_CELL_INFO_LIST, self);
self->display_state_event_id =
mce_display_add_state_changed_handler(display,
ril_cell_info_display_state_cb, self);
self->radio_state_event_id =
ril_radio_add_state_changed_handler(radio,
ril_cell_info_radio_state_cb, self);
self->sim_status_event_id =
ril_sim_card_add_status_changed_handler(self->sim_card,
ril_cell_info_sim_status_cb, self);
self->sim_card_ready = ril_sim_card_ready(sim_card);
ril_cell_info_refresh(self);
ril_cell_info_update_rate(self);
return &self->info;
}
static void ril_cell_info_init(struct ril_cell_info *self)
{
}
static void ril_cell_info_dispose(GObject *object)
{
struct ril_cell_info *self = RIL_CELL_INFO(object);
grilio_channel_remove_handlers(self->io, &self->event_id, 1);
if (self->query_id) {
grilio_channel_cancel_request(self->io, self->query_id, FALSE);
self->query_id = 0;
}
if (self->set_rate_id) {
grilio_channel_cancel_request(self->io, self->set_rate_id,
FALSE);
self->set_rate_id = 0;
}
gutil_disconnect_handlers(self->display,
&self->display_state_event_id, 1);
ril_radio_remove_handlers(self->radio, &self->radio_state_event_id, 1);
ril_sim_card_remove_handlers(self->sim_card,
&self->sim_status_event_id, 1);
G_OBJECT_CLASS(ril_cell_info_parent_class)->dispose(object);
}
static void ril_cell_info_finalize(GObject *object)
{
struct ril_cell_info *self = RIL_CELL_INFO(object);
DBG_(self, "");
g_free(self->log_prefix);
grilio_channel_unref(self->io);
mce_display_unref(self->display);
ril_radio_unref(self->radio);
ril_sim_card_unref(self->sim_card);
g_slist_free_full(self->info.cells, ril_cell_free1);
G_OBJECT_CLASS(ril_cell_info_parent_class)->finalize(object);
}
static void ril_cell_info_class_init(RilCellInfoClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS(klass);
object_class->dispose = ril_cell_info_dispose;
object_class->finalize = ril_cell_info_finalize;
ril_cell_info_signals[SIGNAL_CELLS_CHANGED] =
g_signal_new(SIGNAL_CELLS_CHANGED_NAME,
G_OBJECT_CLASS_TYPE(klass), G_SIGNAL_RUN_FIRST,
0, NULL, NULL, NULL, G_TYPE_NONE, 0);
}
/*
* Local Variables:
* mode: C
* c-basic-offset: 8
* indent-tabs-mode: t
* End:
*/

View File

@@ -0,0 +1,35 @@
/*
* oFono - Open Source Telephony - RIL-based devices
*
* Copyright (C) 2016-2017 Jolla Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#ifndef RIL_CELL_INFO_H
#define RIL_CELL_INFO_H
#include "ril_types.h"
#include <mce_display.h>
#include <sailfish_cell_info.h>
struct sailfish_cell_info *ril_cell_info_new(GRilIoChannel *io,
const char *log_prefix, MceDisplay *display,
struct ril_radio *radio, struct ril_sim_card *sim_card);
#endif /* RIL_CELL_INFO_H */
/*
* Local Variables:
* mode: C
* c-basic-offset: 8
* indent-tabs-mode: t
* End:
*/

View File

@@ -0,0 +1,232 @@
/*
* oFono - Open Source Telephony - RIL-based devices
*
* Copyright (C) 2015-2017 Jolla Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "ril_config.h"
#include "ril_util.h"
#include "ril_log.h"
#include <gutil_intarray.h>
#include <gutil_ints.h>
/* Utilities for parsing ril_subscription.conf */
char *ril_config_get_string(GKeyFile *file, const char *group, const char *key)
{
char *val = g_key_file_get_string(file, group, key, NULL);
if (!val && strcmp(group, RILCONF_SETTINGS_GROUP)) {
/* Check the common section */
val = g_key_file_get_string(file, RILCONF_SETTINGS_GROUP, key,
NULL);
}
return val;
}
char **ril_config_get_strings(GKeyFile *file, const char *group,
const char *key, char delimiter)
{
char *str = ril_config_get_string(file, group, key);
if (str) {
char **strv, **p;
char delimiter_str[2];
delimiter_str[0] = delimiter;
delimiter_str[1] = 0;
strv = g_strsplit(str, delimiter_str, -1);
/* Strip whitespaces */
for (p = strv; *p; p++) {
*p = g_strstrip(*p);
}
g_free(str);
return strv;
}
return NULL;
}
gboolean ril_config_get_integer(GKeyFile *file, const char *group,
const char *key, int *out_value)
{
GError *error = NULL;
int value = g_key_file_get_integer(file, group, key, &error);
if (!error) {
if (out_value) {
*out_value = value;
}
return TRUE;
} else {
g_error_free(error);
if (strcmp(group, RILCONF_SETTINGS_GROUP)) {
/* Check the common section */
error = NULL;
value = g_key_file_get_integer(file,
RILCONF_SETTINGS_GROUP, key, &error);
if (!error) {
if (out_value) {
*out_value = value;
}
return TRUE;
}
g_error_free(error);
}
return FALSE;
}
}
gboolean ril_config_get_boolean(GKeyFile *file, const char *group,
const char *key, gboolean *out_value)
{
GError *error = NULL;
gboolean value = g_key_file_get_boolean(file, group, key, &error);
if (!error) {
if (out_value) {
*out_value = value;
}
return TRUE;
} else {
g_error_free(error);
if (strcmp(group, RILCONF_SETTINGS_GROUP)) {
/* Check the common section */
error = NULL;
value = g_key_file_get_boolean(file,
RILCONF_SETTINGS_GROUP, key, &error);
if (!error) {
if (out_value) {
*out_value = value;
}
return TRUE;
}
g_error_free(error);
}
return FALSE;
}
}
gboolean ril_config_get_flag(GKeyFile *file, const char *group,
const char *key, int flag, int *flags)
{
gboolean value;
if (ril_config_get_boolean(file, group, key, &value)) {
if (value) {
*flags |= flag;
} else {
*flags &= ~flag;
}
return TRUE;
} else {
return FALSE;
}
}
gboolean ril_config_get_enum(GKeyFile *file, const char *group,
const char *key, int *result,
const char *name, int value, ...)
{
char *str = ril_config_get_string(file, group, key);
if (str) {
/*
* Some people are thinking that # is a comment
* anywhere on the line, not just at the beginning
*/
char *comment = strchr(str, '#');
if (comment) *comment = 0;
g_strstrip(str);
if (strcasecmp(str, name)) {
va_list args;
va_start(args, value);
while ((name = va_arg(args, char*)) != NULL) {
value = va_arg(args, int);
if (!strcasecmp(str, name)) {
break;
}
}
va_end(args);
}
if (!name) {
ofono_error("Invalid %s config value (%s)", key, str);
}
g_free(str);
if (name) {
if (result) {
*result = value;
}
return TRUE;
}
}
return FALSE;
}
GUtilInts *ril_config_get_ints(GKeyFile *file, const char *group,
const char *key)
{
char *value = ril_config_get_string(file, group, key);
if (value) {
char **values = g_strsplit(value, ",", -1);
char **ptr = values;
GUtilIntArray *array = gutil_int_array_new();
while (*ptr) {
int val;
if (ril_parse_int(*ptr++, 0, &val)) {
gutil_int_array_append(array, val);
}
}
g_free(value);
g_strfreev(values);
return gutil_int_array_free_to_ints(array);
}
return NULL;
}
char *ril_config_ints_to_string(GUtilInts *ints, char separator)
{
if (ints) {
guint i, n;
const int *data = gutil_ints_get_data(ints, &n);
GString *buf = g_string_new(NULL);
for (i=0; i<n; i++) {
if (buf->len > 0) {
g_string_append_c(buf, separator);
}
g_string_append_printf(buf, "%d", data[i]);
}
return g_string_free(buf, FALSE);
}
return NULL;
}
/*
* Local Variables:
* mode: C
* c-basic-offset: 8
* indent-tabs-mode: t
* End:
*/

View File

@@ -0,0 +1,50 @@
/*
* oFono - Open Source Telephony - RIL-based devices
*
* Copyright (C) 2015-2017 Jolla Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#ifndef RIL_CONFIG_H
#define RIL_CONFIG_H
#include "ril_types.h"
/* Utilities for parsing ril_subscription.conf */
#define RILCONF_SETTINGS_GROUP "Settings"
char *ril_config_get_string(GKeyFile *file, const char *group,
const char *key);
char **ril_config_get_strings(GKeyFile *file, const char *group,
const char *key, char delimiter);
gboolean ril_config_get_integer(GKeyFile *file, const char *group,
const char *key, int *value);
gboolean ril_config_get_boolean(GKeyFile *file, const char *group,
const char *key, gboolean *value);
gboolean ril_config_get_flag(GKeyFile *file, const char *group,
const char *key, int flag, int *flags);
gboolean ril_config_get_enum(GKeyFile *file, const char *group,
const char *key, int *result,
const char *name, int value, ...);
GUtilInts *ril_config_get_ints(GKeyFile *file, const char *group,
const char *key);
char *ril_config_ints_to_string(GUtilInts *ints, char separator);
#endif /* RIL_CONFIG_H */
/*
* Local Variables:
* mode: C
* c-basic-offset: 8
* indent-tabs-mode: t
* End:
*/

View File

@@ -0,0 +1,599 @@
/*
* RIL constants adopted from AOSP's header:
*
* /hardware/ril/reference_ril/ril.h
*
* Copyright (C) 2013 Canonical Ltd.
* Copyright (C) 2013-2017 Jolla Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#ifndef __RIL_CONSTANTS_H
#define __RIL_CONSTANTS_H 1
#define RIL_MAX_UUID_LENGTH 64
/* Error Codes */
enum ril_status {
RIL_E_SUCCESS = 0,
RIL_E_RADIO_NOT_AVAILABLE = 1,
RIL_E_GENERIC_FAILURE = 2,
RIL_E_PASSWORD_INCORRECT = 3,
RIL_E_SIM_PIN2 = 4,
RIL_E_SIM_PUK2 = 5,
RIL_E_REQUEST_NOT_SUPPORTED = 6,
RIL_E_CANCELLED = 7,
RIL_E_OP_NOT_ALLOWED_DURING_VOICE_CALL = 8,
RIL_E_OP_NOT_ALLOWED_BEFORE_REG_TO_NW = 9,
RIL_E_SMS_SEND_FAIL_RETRY = 10,
RIL_E_SIM_ABSENT = 11,
RIL_E_SUBSCRIPTION_NOT_AVAILABLE = 12,
RIL_E_MODE_NOT_SUPPORTED = 13,
RIL_E_FDN_CHECK_FAILURE = 14,
RIL_E_ILLEGAL_SIM_OR_ME = 15,
RIL_E_MISSING_RESOURCE = 16,
RIL_E_NO_SUCH_ELEMENT = 17,
RIL_E_DIAL_MODIFIED_TO_USSD = 18,
RIL_E_DIAL_MODIFIED_TO_SS = 19,
RIL_E_DIAL_MODIFIED_TO_DIAL = 20,
RIL_E_USSD_MODIFIED_TO_DIAL = 21,
RIL_E_USSD_MODIFIED_TO_SS = 22,
RIL_E_USSD_MODIFIED_TO_USSD = 23,
RIL_E_SS_MODIFIED_TO_DIAL = 24,
RIL_E_SS_MODIFIED_TO_USSD = 25,
RIL_E_SUBSCRIPTION_NOT_SUPPORTED = 26,
RIL_E_SS_MODIFIED_TO_SS = 27,
RIL_E_LCE_NOT_SUPPORTED = 36,
RIL_E_NO_MEMORY = 37,
RIL_E_INTERNAL_ERR = 38,
RIL_E_SYSTEM_ERR = 39,
RIL_E_MODEM_ERR = 40,
RIL_E_INVALID_STATE = 41,
RIL_E_NO_RESOURCES = 42,
RIL_E_SIM_ERR = 43,
RIL_E_INVALID_ARGUMENTS = 44,
RIL_E_INVALID_SIM_STATE = 45,
RIL_E_INVALID_MODEM_STATE = 46,
RIL_E_INVALID_CALL_ID = 47,
RIL_E_NO_SMS_TO_ACK = 48,
RIL_E_NETWORK_ERR = 49,
RIL_E_REQUEST_RATE_LIMITED = 50,
RIL_E_SIM_BUSY = 51,
RIL_E_SIM_FULL = 52,
RIL_E_NETWORK_REJECT = 53,
RIL_E_OPERATION_NOT_ALLOWED = 54,
RIL_E_EMPTY_RECORD = 55,
RIL_E_INVALID_SMS_FORMAT = 56,
RIL_E_ENCODING_ERR = 57,
RIL_E_INVALID_SMSC_ADDRESS = 58,
RIL_E_NO_SUCH_ENTRY = 59,
RIL_E_NETWORK_NOT_READY = 60,
RIL_E_NOT_PROVISIONED = 61,
RIL_E_NO_SUBSCRIPTION = 62,
RIL_E_NO_NETWORK_FOUND = 63,
RIL_E_DEVICE_IN_USE = 64,
RIL_E_ABORTED = 65,
RIL_E_INVALID_RESPONSE = 66
};
/* call states */
enum ril_call_state {
RIL_CALL_ACTIVE = 0,
RIL_CALL_HOLDING = 1,
RIL_CALL_DIALING = 2,
RIL_CALL_ALERTING = 3,
RIL_CALL_INCOMING = 4,
RIL_CALL_WAITING = 5
};
/* Radio state */
enum ril_radio_state {
RADIO_STATE_OFF = 0,
RADIO_STATE_UNAVAILABLE = 1,
RADIO_STATE_SIM_NOT_READY = 2,
RADIO_STATE_SIM_LOCKED_OR_ABSENT = 3,
RADIO_STATE_SIM_READY = 4,
RADIO_STATE_RUIM_NOT_READY = 5,
RADIO_STATE_RUIM_READY = 6,
RADIO_STATE_RUIM_LOCKED_OR_ABSENT = 7,
RADIO_STATE_NV_NOT_READY = 8,
RADIO_STATE_NV_READY = 9,
RADIO_STATE_ON = 10
};
/* Preferred network types */
enum ril_pref_net_type {
PREF_NET_TYPE_GSM_WCDMA = 0,
PREF_NET_TYPE_GSM_ONLY = 1,
PREF_NET_TYPE_WCDMA = 2,
PREF_NET_TYPE_GSM_WCDMA_AUTO = 3,
PREF_NET_TYPE_CDMA_EVDO_AUTO = 4,
PREF_NET_TYPE_CDMA_ONLY = 5,
PREF_NET_TYPE_EVDO_ONLY = 6,
PREF_NET_TYPE_GSM_WCDMA_CDMA_EVDO_AUTO = 7,
PREF_NET_TYPE_LTE_CDMA_EVDO = 8,
PREF_NET_TYPE_LTE_GSM_WCDMA = 9,
PREF_NET_TYPE_LTE_CMDA_EVDO_GSM_WCDMA = 10,
PREF_NET_TYPE_LTE_ONLY = 11,
PREF_NET_TYPE_LTE_WCDMA = 12
};
/* Radio technologies */
enum ril_radio_tech {
RADIO_TECH_UNKNOWN = 0,
RADIO_TECH_GPRS = 1,
RADIO_TECH_EDGE = 2,
RADIO_TECH_UMTS = 3,
RADIO_TECH_IS95A = 4,
RADIO_TECH_IS95B = 5,
RADIO_TECH_1xRTT = 6,
RADIO_TECH_EVDO_0 = 7,
RADIO_TECH_EVDO_A = 8,
RADIO_TECH_HSDPA = 9,
RADIO_TECH_HSUPA = 10,
RADIO_TECH_HSPA = 11,
RADIO_TECH_EVDO_B = 12,
RADIO_TECH_EHRPD = 13,
RADIO_TECH_LTE = 14,
RADIO_TECH_HSPAP = 15,
RADIO_TECH_GSM = 16,
RADIO_TECH_TD_SCDMA = 17,
RADIO_TECH_IWLAN = 18,
RADIO_TECH_LTE_CA = 19
};
/* Radio capabilities */
enum ril_radio_access_family {
RAF_GPRS = (1 << RADIO_TECH_GPRS),
RAF_EDGE = (1 << RADIO_TECH_EDGE),
RAF_UMTS = (1 << RADIO_TECH_UMTS),
RAF_IS95A = (1 << RADIO_TECH_IS95A),
RAF_IS95B = (1 << RADIO_TECH_IS95B),
RAF_1xRTT = (1 << RADIO_TECH_1xRTT),
RAF_EVDO_0 = (1 << RADIO_TECH_EVDO_0),
RAF_EVDO_A = (1 << RADIO_TECH_EVDO_A),
RAF_HSDPA = (1 << RADIO_TECH_HSDPA),
RAF_HSUPA = (1 << RADIO_TECH_HSUPA),
RAF_HSPA = (1 << RADIO_TECH_HSPA),
RAF_EVDO_B = (1 << RADIO_TECH_EVDO_B),
RAF_EHRPD = (1 << RADIO_TECH_EHRPD),
RAF_LTE = (1 << RADIO_TECH_LTE),
RAF_HSPAP = (1 << RADIO_TECH_HSPAP),
RAF_GSM = (1 << RADIO_TECH_GSM),
RAF_TD_SCDMA = (1 << RADIO_TECH_TD_SCDMA),
RAF_LTE_CA = (1 << RADIO_TECH_LTE_CA)
};
enum ril_radio_capability_phase {
RC_PHASE_CONFIGURED = 0,
RC_PHASE_START = 1,
RC_PHASE_APPLY = 2,
RC_PHASE_UNSOL_RSP = 3,
RC_PHASE_FINISH = 4
};
enum ril_radio_capability_status {
RC_STATUS_NONE = 0,
RC_STATUS_SUCCESS = 1,
RC_STATUS_FAIL = 2
};
#define RIL_RADIO_CAPABILITY_VERSION 1
struct ril_radio_capability {
int version;
int session;
enum ril_radio_capability_phase phase;
enum ril_radio_access_family rat;
char logicalModemUuid[RIL_MAX_UUID_LENGTH];
int status;
};
enum ril_uicc_subscription_action {
RIL_UICC_SUBSCRIPTION_DEACTIVATE = 0,
RIL_UICC_SUBSCRIPTION_ACTIVATE = 1
};
/* See RIL_REQUEST_LAST_CALL_FAIL_CAUSE */
enum ril_call_fail_cause {
CALL_FAIL_UNOBTAINABLE_NUMBER = 1,
CALL_FAIL_NO_ROUTE_TO_DESTINATION = 3,
CALL_FAIL_CHANNEL_UNACCEPTABLE = 6,
CALL_FAIL_OPERATOR_DETERMINED_BARRING = 8,
CALL_FAIL_NORMAL = 16,
CALL_FAIL_BUSY = 17,
CALL_FAIL_NO_USER_RESPONDING = 18,
CALL_FAIL_NO_ANSWER_FROM_USER = 19,
CALL_FAIL_CALL_REJECTED = 21,
CALL_FAIL_NUMBER_CHANGED = 22,
CALL_FAIL_DESTINATION_OUT_OF_ORDER = 27,
CALL_FAIL_INVALID_NUMBER_FORMAT = 28,
CALL_FAIL_FACILITY_REJECTED = 29,
CALL_FAIL_RESP_TO_STATUS_ENQUIRY = 30,
CALL_FAIL_NORMAL_UNSPECIFIED = 31,
CALL_FAIL_CONGESTION = 34,
CALL_FAIL_NETWORK_OUT_OF_ORDER = 38,
CALL_FAIL_TEMPORARY_FAILURE = 41,
CALL_FAIL_SWITCHING_EQUIPMENT_CONGESTION = 42,
CALL_FAIL_ACCESS_INFORMATION_DISCARDED = 43,
CALL_FAIL_REQUESTED_CIRCUIT_OR_CHANNEL_NOT_AVAILABLE = 44,
CALL_FAIL_RESOURCES_UNAVAILABLE_OR_UNSPECIFIED = 47,
CALL_FAIL_QOS_UNAVAILABLE = 49,
CALL_FAIL_REQUESTED_FACILITY_NOT_SUBSCRIBED = 50,
CALL_FAIL_INCOMING_CALLS_BARRED_WITHIN_CUG = 55,
CALL_FAIL_BEARER_CAPABILITY_NOT_AUTHORIZED = 57,
CALL_FAIL_BEARER_CAPABILITY_UNAVAILABLE = 58,
CALL_FAIL_SERVICE_OPTION_NOT_AVAILABLE = 63,
CALL_FAIL_BEARER_SERVICE_NOT_IMPLEMENTED = 65,
CALL_FAIL_ACM_LIMIT_EXCEEDED = 68,
CALL_FAIL_REQUESTED_FACILITY_NOT_IMPLEMENTED = 69,
CALL_FAIL_ONLY_DIGITAL_INFORMATION_BEARER_AVAILABLE = 70,
CALL_FAIL_SERVICE_OR_OPTION_NOT_IMPLEMENTED = 79,
CALL_FAIL_INVALID_TRANSACTION_IDENTIFIER = 81,
CALL_FAIL_USER_NOT_MEMBER_OF_CUG = 87,
CALL_FAIL_INCOMPATIBLE_DESTINATION = 88,
CALL_FAIL_INVALID_TRANSIT_NW_SELECTION = 91,
CALL_FAIL_SEMANTICALLY_INCORRECT_MESSAGE = 95,
CALL_FAIL_INVALID_MANDATORY_INFORMATION = 96,
CALL_FAIL_MESSAGE_TYPE_NON_IMPLEMENTED = 97,
CALL_FAIL_MESSAGE_TYPE_NOT_COMPATIBLE_WITH_PROTOCOL_STATE = 98,
CALL_FAIL_INFORMATION_ELEMENT_NON_EXISTENT = 99,
CALL_FAIL_CONDITIONAL_IE_ERROR = 100,
CALL_FAIL_MESSAGE_NOT_COMPATIBLE_WITH_PROTOCOL_STATE = 101,
CALL_FAIL_RECOVERY_ON_TIMER_EXPIRED = 102,
CALL_FAIL_PROTOCOL_ERROR_UNSPECIFIED = 111,
CALL_FAIL_INTERWORKING_UNSPECIFIED = 127,
CALL_FAIL_CALL_BARRED = 240,
CALL_FAIL_FDN_BLOCKED = 241,
CALL_FAIL_IMSI_UNKNOWN_IN_VLR = 242,
CALL_FAIL_IMEI_NOT_ACCEPTED = 243,
CALL_FAIL_DIAL_MODIFIED_TO_USSD = 244,
CALL_FAIL_DIAL_MODIFIED_TO_SS = 245,
CALL_FAIL_DIAL_MODIFIED_TO_DIAL = 246,
CALL_FAIL_ERROR_UNSPECIFIED = 0xffff,
/* Not defined in ril.h but valid 3GPP specific cause values
* for call control. See 3GPP TS 24.008 Annex H. */
CALL_FAIL_ANONYMOUS_CALL_REJECTION = 24,
CALL_FAIL_PRE_EMPTION = 25
};
enum ril_data_call_fail_cause {
PDP_FAIL_NONE = 0,
PDP_FAIL_OPERATOR_BARRED = 0x08,
PDP_FAIL_INSUFFICIENT_RESOURCES = 0x1A,
PDP_FAIL_MISSING_UKNOWN_APN = 0x1B,
PDP_FAIL_UNKNOWN_PDP_ADDRESS_TYPE = 0x1C,
PDP_FAIL_USER_AUTHENTICATION = 0x1D,
PDP_FAIL_ACTIVATION_REJECT_GGSN = 0x1E,
PDP_FAIL_ACTIVATION_REJECT_UNSPECIFIED = 0x1F,
PDP_FAIL_SERVICE_OPTION_NOT_SUPPORTED = 0x20,
PDP_FAIL_SERVICE_OPTION_NOT_SUBSCRIBED = 0x21,
PDP_FAIL_SERVICE_OPTION_OUT_OF_ORDER = 0x22,
PDP_FAIL_NSAPI_IN_USE = 0x23,
PDP_FAIL_REGULAR_DEACTIVATION = 0x24,
PDP_FAIL_ONLY_IPV4_ALLOWED = 0x32,
PDP_FAIL_ONLY_IPV6_ALLOWED = 0x33,
PDP_FAIL_ONLY_SINGLE_BEARER_ALLOWED = 0x34,
PDP_FAIL_PROTOCOL_ERRORS = 0x6F,
PDP_FAIL_VOICE_REGISTRATION_FAIL = -1,
PDP_FAIL_DATA_REGISTRATION_FAIL = -2,
PDP_FAIL_SIGNAL_LOST = -3,
PDP_FAIL_PREF_RADIO_TECH_CHANGED = -4,
PDP_FAIL_RADIO_POWER_OFF = -5,
PDP_FAIL_TETHERED_CALL_ACTIVE = -6,
PDP_FAIL_ERROR_UNSPECIFIED = 0xffff
};
/* RIL_REQUEST_DEACTIVATE_DATA_CALL parameter */
#define RIL_DEACTIVATE_DATA_CALL_NO_REASON 0
#define RIL_DEACTIVATE_DATA_CALL_RADIO_SHUTDOWN 1
/* RIL_REQUEST_SETUP_DATA_CALL */
enum ril_data_profile {
RIL_DATA_PROFILE_DEFAULT = 0,
RIL_DATA_PROFILE_TETHERED = 1,
RIL_DATA_PROFILE_IMS = 2,
RIL_DATA_PROFILE_FOTA = 3,
RIL_DATA_PROFILE_CBS = 4,
RIL_DATA_PROFILE_OEM_BASE = 1000,
RIL_DATA_PROFILE_INVALID = 0xFFFFFFFF
};
enum ril_auth {
RIL_AUTH_NONE = 0,
RIL_AUTH_PAP = 1,
RIL_AUTH_CHAP = 2,
RIL_AUTH_BOTH = 3
};
#define RIL_CARD_MAX_APPS 8
/* SIM card states */
enum ril_card_state {
RIL_CARDSTATE_UNKNOWN = -1,
RIL_CARDSTATE_ABSENT = 0,
RIL_CARDSTATE_PRESENT = 1,
RIL_CARDSTATE_ERROR = 2
};
/* SIM personalization substates */
enum ril_perso_substate {
RIL_PERSOSUBSTATE_UNKNOWN = 0,
RIL_PERSOSUBSTATE_IN_PROGRESS = 1,
RIL_PERSOSUBSTATE_READY = 2,
RIL_PERSOSUBSTATE_SIM_NETWORK = 3,
RIL_PERSOSUBSTATE_SIM_NETWORK_SUBSET = 4,
RIL_PERSOSUBSTATE_SIM_CORPORATE = 5,
RIL_PERSOSUBSTATE_SIM_SERVICE_PROVIDER = 6,
RIL_PERSOSUBSTATE_SIM_SIM = 7,
RIL_PERSOSUBSTATE_SIM_NETWORK_PUK = 8,
RIL_PERSOSUBSTATE_SIM_NETWORK_SUBSET_PUK = 9,
RIL_PERSOSUBSTATE_SIM_CORPORATE_PUK = 10,
RIL_PERSOSUBSTATE_SIM_SERVICE_PROVIDER_PUK = 11,
RIL_PERSOSUBSTATE_SIM_SIM_PUK = 12,
RIL_PERSOSUBSTATE_RUIM_NETWORK1 = 13,
RIL_PERSOSUBSTATE_RUIM_NETWORK2 = 14,
RIL_PERSOSUBSTATE_RUIM_HRPD = 15,
RIL_PERSOSUBSTATE_RUIM_CORPORATE = 16,
RIL_PERSOSUBSTATE_RUIM_SERVICE_PROVIDER = 17,
RIL_PERSOSUBSTATE_RUIM_RUIM = 18,
RIL_PERSOSUBSTATE_RUIM_NETWORK1_PUK = 19,
RIL_PERSOSUBSTATE_RUIM_NETWORK2_PUK = 20,
RIL_PERSOSUBSTATE_RUIM_HRPD_PUK = 21,
RIL_PERSOSUBSTATE_RUIM_CORPORATE_PUK = 22,
RIL_PERSOSUBSTATE_RUIM_SERVICE_PROVIDER_PUK = 23,
RIL_PERSOSUBSTATE_RUIM_RUIM_PUK = 24
};
/* SIM - App states */
enum ril_app_state {
RIL_APPSTATE_ILLEGAL = -1,
RIL_APPSTATE_UNKNOWN = 0,
RIL_APPSTATE_DETECTED = 1,
RIL_APPSTATE_PIN = 2,
RIL_APPSTATE_PUK = 3,
RIL_APPSTATE_SUBSCRIPTION_PERSO = 4,
RIL_APPSTATE_READY = 5
};
/* SIM - PIN states */
enum ril_pin_state {
RIL_PINSTATE_UNKNOWN = 0,
RIL_PINSTATE_ENABLED_NOT_VERIFIED = 1,
RIL_PINSTATE_ENABLED_VERIFIED = 2,
RIL_PINSTATE_DISABLED = 3,
RIL_PINSTATE_ENABLED_BLOCKED = 4,
RIL_PINSTATE_ENABLED_PERM_BLOCKED = 5
};
/* SIM - App types */
enum ril_app_type {
RIL_APPTYPE_UNKNOWN = 0,
RIL_APPTYPE_SIM = 1,
RIL_APPTYPE_USIM = 2,
RIL_APPTYPE_RUIM = 3,
RIL_APPTYPE_CSIM = 4,
RIL_APPTYPE_ISIM = 5
};
/* Cell info */
enum ril_cell_info_type {
RIL_CELL_INFO_TYPE_NONE = 0,
RIL_CELL_INFO_TYPE_GSM = 1,
RIL_CELL_INFO_TYPE_CDMA = 2,
RIL_CELL_INFO_TYPE_LTE = 3,
RIL_CELL_INFO_TYPE_WCDMA = 4,
RIL_CELL_INFO_TYPE_TD_SCDMA = 5
};
/* RIL Request Messages, ofono -> rild */
#define RIL_REQUEST_GET_SIM_STATUS 1
#define RIL_REQUEST_ENTER_SIM_PIN 2
#define RIL_REQUEST_ENTER_SIM_PUK 3
#define RIL_REQUEST_ENTER_SIM_PIN2 4
#define RIL_REQUEST_ENTER_SIM_PUK2 5
#define RIL_REQUEST_CHANGE_SIM_PIN 6
#define RIL_REQUEST_CHANGE_SIM_PIN2 7
#define RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION 8
#define RIL_REQUEST_GET_CURRENT_CALLS 9
#define RIL_REQUEST_DIAL 10
#define RIL_REQUEST_GET_IMSI 11
#define RIL_REQUEST_HANGUP 12
#define RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND 13
#define RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND 14
#define RIL_REQUEST_SWITCH_HOLDING_AND_ACTIVE 15
#define RIL_REQUEST_CONFERENCE 16
#define RIL_REQUEST_UDUB 17
#define RIL_REQUEST_LAST_CALL_FAIL_CAUSE 18
#define RIL_REQUEST_SIGNAL_STRENGTH 19
#define RIL_REQUEST_VOICE_REGISTRATION_STATE 20
#define RIL_REQUEST_DATA_REGISTRATION_STATE 21
#define RIL_REQUEST_OPERATOR 22
#define RIL_REQUEST_RADIO_POWER 23
#define RIL_REQUEST_DTMF 24
#define RIL_REQUEST_SEND_SMS 25
#define RIL_REQUEST_SEND_SMS_EXPECT_MORE 26
#define RIL_REQUEST_SETUP_DATA_CALL 27
#define RIL_REQUEST_SIM_IO 28
#define RIL_REQUEST_SEND_USSD 29
#define RIL_REQUEST_CANCEL_USSD 30
#define RIL_REQUEST_GET_CLIR 31
#define RIL_REQUEST_SET_CLIR 32
#define RIL_REQUEST_QUERY_CALL_FORWARD_STATUS 33
#define RIL_REQUEST_SET_CALL_FORWARD 34
#define RIL_REQUEST_QUERY_CALL_WAITING 35
#define RIL_REQUEST_SET_CALL_WAITING 36
#define RIL_REQUEST_SMS_ACKNOWLEDGE 37
#define RIL_REQUEST_GET_IMEI 38
#define RIL_REQUEST_GET_IMEISV 39
#define RIL_REQUEST_ANSWER 40
#define RIL_REQUEST_DEACTIVATE_DATA_CALL 41
#define RIL_REQUEST_QUERY_FACILITY_LOCK 42
#define RIL_REQUEST_SET_FACILITY_LOCK 43
#define RIL_REQUEST_CHANGE_BARRING_PASSWORD 44
#define RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE 45
#define RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC 46
#define RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL 47
#define RIL_REQUEST_QUERY_AVAILABLE_NETWORKS 48
#define RIL_REQUEST_DTMF_START 49
#define RIL_REQUEST_DTMF_STOP 50
#define RIL_REQUEST_BASEBAND_VERSION 51
#define RIL_REQUEST_SEPARATE_CONNECTION 52
#define RIL_REQUEST_SET_MUTE 53
#define RIL_REQUEST_GET_MUTE 54
#define RIL_REQUEST_QUERY_CLIP 55
#define RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE 56
#define RIL_REQUEST_DATA_CALL_LIST 57
#define RIL_REQUEST_RESET_RADIO 58
#define RIL_REQUEST_OEM_HOOK_RAW 59
#define RIL_REQUEST_OEM_HOOK_STRINGS 60
#define RIL_REQUEST_SCREEN_STATE 61
#define RIL_REQUEST_SET_SUPP_SVC_NOTIFICATION 62
#define RIL_REQUEST_WRITE_SMS_TO_SIM 63
#define RIL_REQUEST_DELETE_SMS_ON_SIM 64
#define RIL_REQUEST_SET_BAND_MODE 65
#define RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE 66
#define RIL_REQUEST_STK_GET_PROFILE 67
#define RIL_REQUEST_STK_SET_PROFILE 68
#define RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND 69
#define RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE 70
#define RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM 71
#define RIL_REQUEST_EXPLICIT_CALL_TRANSFER 72
#define RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE 73
#define RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE 74
#define RIL_REQUEST_GET_NEIGHBORING_CELL_IDS 75
#define RIL_REQUEST_SET_LOCATION_UPDATES 76
#define RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE 77
#define RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE 78
#define RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE 79
#define RIL_REQUEST_SET_TTY_MODE 80
#define RIL_REQUEST_QUERY_TTY_MODE 81
#define RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE 82
#define RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE 83
#define RIL_REQUEST_CDMA_FLASH 84
#define RIL_REQUEST_CDMA_BURST_DTMF 85
#define RIL_REQUEST_CDMA_VALIDATE_AND_WRITE_AKEY 86
#define RIL_REQUEST_CDMA_SEND_SMS 87
#define RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE 88
#define RIL_REQUEST_GSM_GET_BROADCAST_SMS_CONFIG 89
#define RIL_REQUEST_GSM_SET_BROADCAST_SMS_CONFIG 90
#define RIL_REQUEST_GSM_SMS_BROADCAST_ACTIVATION 91
#define RIL_REQUEST_CDMA_GET_BROADCAST_SMS_CONFIG 92
#define RIL_REQUEST_CDMA_SET_BROADCAST_SMS_CONFIG 93
#define RIL_REQUEST_CDMA_SMS_BROADCAST_ACTIVATION 94
#define RIL_REQUEST_CDMA_SUBSCRIPTION 95
#define RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM 96
#define RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM 97
#define RIL_REQUEST_DEVICE_IDENTITY 98
#define RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE 99
#define RIL_REQUEST_GET_SMSC_ADDRESS 100
#define RIL_REQUEST_SET_SMSC_ADDRESS 101
#define RIL_REQUEST_REPORT_SMS_MEMORY_STATUS 102
#define RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING 103
#define RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE 104
#define RIL_REQUEST_ISIM_AUTHENTICATION 105
#define RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU 106
#define RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS 107
#define RIL_REQUEST_VOICE_RADIO_TECH 108
#define RIL_REQUEST_GET_CELL_INFO_LIST 109
#define RIL_REQUEST_SET_UNSOL_CELL_INFO_LIST_RATE 110
#define RIL_REQUEST_SET_INITIAL_ATTACH_APN 111
#define RIL_REQUEST_IMS_REGISTRATION_STATE 112
#define RIL_REQUEST_IMS_SEND_SMS 113
#define RIL_REQUEST_SIM_TRANSMIT_APDU_BASIC 114
#define RIL_REQUEST_SIM_OPEN_CHANNEL 115
#define RIL_REQUEST_SIM_CLOSE_CHANNEL 116
#define RIL_REQUEST_SIM_TRANSMIT_APDU_CHANNEL 117
#define RIL_REQUEST_NV_READ_ITEM 118
#define RIL_REQUEST_NV_WRITE_ITEM 119
#define RIL_REQUEST_NV_WRITE_CDMA_PRL 120
#define RIL_REQUEST_NV_RESET_CONFIG 121
/* SET_UICC_SUBSCRIPTION was 115 in v9 and 122 in v10 and later */
#define RIL_REQUEST_V9_SET_UICC_SUBSCRIPTION 115
#define RIL_REQUEST_SET_UICC_SUBSCRIPTION 122
#define RIL_REQUEST_ALLOW_DATA 123
#define RIL_REQUEST_GET_HARDWARE_CONFIG 124
#define RIL_REQUEST_SIM_AUTHENTICATION 125
#define RIL_REQUEST_GET_DC_RT_INFO 126
#define RIL_REQUEST_SET_DC_RT_INFO_RATE 127
#define RIL_REQUEST_SET_DATA_PROFILE 128
#define RIL_REQUEST_SHUTDOWN 129
#define RIL_REQUEST_GET_RADIO_CAPABILITY 130
#define RIL_REQUEST_SET_RADIO_CAPABILITY 131
/* RIL Unsolicited Messages, rild -> ofono */
#define RIL_UNSOL_RESPONSE_BASE 1000
#define RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED 1000
#define RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED 1001
#define RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED 1002
#define RIL_UNSOL_RESPONSE_NEW_SMS 1003
#define RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT 1004
#define RIL_UNSOL_RESPONSE_NEW_SMS_ON_SIM 1005
#define RIL_UNSOL_ON_USSD 1006
#define RIL_UNSOL_ON_USSD_REQUEST 1007
#define RIL_UNSOL_NITZ_TIME_RECEIVED 1008
#define RIL_UNSOL_SIGNAL_STRENGTH 1009
#define RIL_UNSOL_DATA_CALL_LIST_CHANGED 1010
#define RIL_UNSOL_SUPP_SVC_NOTIFICATION 1011
#define RIL_UNSOL_STK_SESSION_END 1012
#define RIL_UNSOL_STK_PROACTIVE_COMMAND 1013
#define RIL_UNSOL_STK_EVENT_NOTIFY 1014
#define RIL_UNSOL_STK_CALL_SETUP 1015
#define RIL_UNSOL_SIM_SMS_STORAGE_FULL 1016
#define RIL_UNSOL_SIM_REFRESH 1017
#define RIL_UNSOL_CALL_RING 1018
#define RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED 1019
#define RIL_UNSOL_RESPONSE_CDMA_NEW_SMS 1020
#define RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS 1021
#define RIL_UNSOL_CDMA_RUIM_SMS_STORAGE_FULL 1022
#define RIL_UNSOL_RESTRICTED_STATE_CHANGED 1023
#define RIL_UNSOL_ENTER_EMERGENCY_CALLBACK_MODE 1024
#define RIL_UNSOL_CDMA_CALL_WAITING 1025
#define RIL_UNSOL_CDMA_OTA_PROVISION_STATUS 1026
#define RIL_UNSOL_CDMA_INFO_REC 1027
#define RIL_UNSOL_OEM_HOOK_RAW 1028
#define RIL_UNSOL_RINGBACK_TONE 1029
#define RIL_UNSOL_RESEND_INCALL_MUTE 1030
#define RIL_UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED 1031
#define RIL_UNSOL_CDMA_PRL_CHANGED 1032
#define RIL_UNSOL_EXIT_EMERGENCY_CALLBACK_MODE 1033
#define RIL_UNSOL_RIL_CONNECTED 1034
#define RIL_UNSOL_VOICE_RADIO_TECH_CHANGED 1035
#define RIL_UNSOL_CELL_INFO_LIST 1036
#define RIL_UNSOL_RESPONSE_IMS_NETWORK_STATE_CHANGED 1037
#define RIL_UNSOL_UICC_SUBSCRIPTION_STATUS_CHANGED 1038
#define RIL_UNSOL_SRVCC_STATE_NOTIFY 1039
#define RIL_UNSOL_HARDWARE_CONFIG_CHANGED 1040
#define RIL_UNSOL_DC_RT_INFO_CHANGED 1041
#define RIL_UNSOL_RADIO_CAPABILITY 1042
#define RIL_UNSOL_ON_SS 1043
#define RIL_UNSOL_STK_CC_ALPHA_NOTIFY 1044
/* A special request, ofono -> rild */
#define RIL_RESPONSE_ACKNOWLEDGEMENT 800
/* Suplementary services Service class*/
#define SERVICE_CLASS_NONE 0
/* RIL_FACILITY_LOCK parameters */
#define RIL_FACILITY_UNLOCK "0"
#define RIL_FACILITY_LOCK "1"
#endif /*__RIL_CONSTANTS_H */
/*
* Local Variables:
* mode: C
* c-basic-offset: 8
* indent-tabs-mode: t
* End:
*/

1701
ofono/drivers/ril/ril_data.c Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,143 @@
/*
* oFono - Open Source Telephony - RIL-based devices
*
* Copyright (C) 2016-2017 Jolla Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#ifndef RIL_DATA_H
#define RIL_DATA_H
#include "ril_types.h"
#include <ofono/gprs-context.h>
enum ril_data_call_active {
RIL_DATA_CALL_INACTIVE = 0,
RIL_DATA_CALL_LINK_DOWN = 1,
RIL_DATA_CALL_ACTIVE = 2
};
struct ril_data_call {
int cid;
enum ril_data_call_fail_cause status;
enum ril_data_call_active active;
enum ofono_gprs_proto prot;
int retry_time;
int mtu;
char *ifname;
char **dnses;
char **gateways;
char **addresses;
};
struct ril_data_call_list {
guint version;
guint num;
GSList *calls;
};
struct ril_data {
GObject object;
struct ril_data_priv *priv;
struct ril_data_call_list *data_calls;
};
enum ril_data_manager_flags {
RIL_DATA_MANAGER_3GLTE_HANDOVER = 0x01
};
enum ril_data_allow_data_opt {
RIL_ALLOW_DATA_AUTO,
RIL_ALLOW_DATA_ENABLED,
RIL_ALLOW_DATA_DISABLED
};
enum ril_data_call_format {
RIL_DATA_CALL_FORMAT_AUTO,
RIL_DATA_CALL_FORMAT_6 = 6,
RIL_DATA_CALL_FORMAT_9 = 9,
RIL_DATA_CALL_FORMAT_11 = 11
};
struct ril_data_options {
enum ril_data_allow_data_opt allow_data;
enum ril_data_call_format data_call_format;
unsigned int data_call_retry_limit;
unsigned int data_call_retry_delay_ms;
};
enum ril_data_role {
RIL_DATA_ROLE_NONE, /* Data not allowed */
RIL_DATA_ROLE_MMS, /* Data is allowed at any speed */
RIL_DATA_ROLE_INTERNET /* Data is allowed at full speed */
};
struct ril_data_manager;
struct ril_data_manager *ril_data_manager_new(enum ril_data_manager_flags flg);
struct ril_data_manager *ril_data_manager_ref(struct ril_data_manager *dm);
void ril_data_manager_unref(struct ril_data_manager *dm);
void ril_data_manager_assert_data_on(struct ril_data_manager *dm);
typedef void (*ril_data_cb_t)(struct ril_data *data, void *arg);
typedef void (*ril_data_call_setup_cb_t)(struct ril_data *data,
int ril_status, const struct ril_data_call *call,
void *arg);
typedef void (*ril_data_call_deactivate_cb_t)(struct ril_data *data,
int ril_status, void *arg);
struct ril_data *ril_data_new(struct ril_data_manager *dm, const char *name,
struct ril_radio *radio, struct ril_network *network,
GRilIoChannel *io, const struct ril_data_options *options,
const struct ril_slot_config *config,
struct ril_vendor_hook *vendor_hook);
struct ril_data *ril_data_ref(struct ril_data *data);
void ril_data_unref(struct ril_data *data);
gboolean ril_data_allowed(struct ril_data *data);
void ril_data_poll_call_state(struct ril_data *data);
gulong ril_data_add_allow_changed_handler(struct ril_data *data,
ril_data_cb_t cb, void *arg);
gulong ril_data_add_calls_changed_handler(struct ril_data *data,
ril_data_cb_t cb, void *arg);
void ril_data_remove_handler(struct ril_data *data, gulong id);
void ril_data_allow(struct ril_data *data, enum ril_data_role role);
struct ril_data_request;
struct ril_data_request *ril_data_call_setup(struct ril_data *data,
const struct ofono_gprs_primary_context *ctx,
ril_data_call_setup_cb_t cb, void *arg);
struct ril_data_request *ril_data_call_deactivate(struct ril_data *data,
int cid, ril_data_call_deactivate_cb_t cb, void *arg);
void ril_data_request_detach(struct ril_data_request *req);
void ril_data_request_cancel(struct ril_data_request *req);
void ril_data_call_free(struct ril_data_call *call);
struct ril_data_call *ril_data_call_dup(const struct ril_data_call *call);
struct ril_data_call *ril_data_call_find(struct ril_data_call_list *list,
int cid);
const char *ril_data_ofono_protocol_to_ril(enum ofono_gprs_proto proto);
int ril_data_protocol_to_ofono(const gchar *str);
/* Constructors of various kinds of RIL requests */
GRilIoRequest *ril_request_allow_data_new(gboolean allow);
GRilIoRequest *ril_request_deactivate_data_call_new(int cid);
#endif /* RIL_DATA_H */
/*
* Local Variables:
* mode: C
* c-basic-offset: 8
* indent-tabs-mode: t
* End:
*/

View File

@@ -0,0 +1,225 @@
/*
* oFono - Open Source Telephony - RIL-based devices
*
* Copyright (C) 2015-2017 Jolla Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "ril_plugin.h"
#include "ril_util.h"
#include "ril_log.h"
#include <gutil_idlequeue.h>
/*
* TODO: No public RIL api to query manufacturer or model.
* Check where to get, could /system/build.prop be updated to have good values?
*/
enum ril_devinfo_cb_tag {
DEVINFO_QUERY_SERIAL = 1,
DEVINFO_QUERY_SVN
};
struct ril_devinfo {
struct ofono_devinfo *info;
GRilIoQueue *q;
GUtilIdleQueue *iq;
char *log_prefix;
char *imeisv;
char *imei;
};
struct ril_devinfo_cbd {
struct ril_devinfo *di;
ofono_devinfo_query_cb_t cb;
gpointer data;
};
#define DBG_(self,fmt,args...) DBG("%s" fmt, (self)->log_prefix, ##args)
#define ril_devinfo_cbd_free g_free
static inline struct ril_devinfo *ril_devinfo_get_data(
struct ofono_devinfo *info)
{
return ofono_devinfo_get_data(info);
}
struct ril_devinfo_cbd *ril_devinfo_cbd_new(struct ril_devinfo *di,
ofono_devinfo_query_cb_t cb, void *data)
{
struct ril_devinfo_cbd *cbd = g_new0(struct ril_devinfo_cbd, 1);
cbd->di = di;
cbd->cb = cb;
cbd->data = data;
return cbd;
}
static void ril_devinfo_query_unsupported(struct ofono_devinfo *info,
ofono_devinfo_query_cb_t cb, void *data)
{
struct ofono_error error;
cb(ril_error_failure(&error), "", data);
}
static void ril_devinfo_query_revision_cb(GRilIoChannel *io, int status,
const void *data, guint len, void *user_data)
{
struct ofono_error error;
struct ril_devinfo_cbd *cbd = user_data;
if (status == RIL_E_SUCCESS) {
char *res;
GRilIoParser rilp;
grilio_parser_init(&rilp, data, len);
res = grilio_parser_get_utf8(&rilp);
DBG_(cbd->di, "%s", res);
cbd->cb(ril_error_ok(&error), res ? res : "", cbd->data);
g_free(res);
} else {
cbd->cb(ril_error_failure(&error), NULL, cbd->data);
}
}
static void ril_devinfo_query_revision(struct ofono_devinfo *info,
ofono_devinfo_query_cb_t cb, void *data)
{
struct ril_devinfo *di = ril_devinfo_get_data(info);
DBG_(di, "");
grilio_queue_send_request_full(di->q, NULL,
RIL_REQUEST_BASEBAND_VERSION,
ril_devinfo_query_revision_cb,
ril_devinfo_cbd_free,
ril_devinfo_cbd_new(di, cb, data));
}
static void ril_devinfo_query_serial_cb(gpointer user_data)
{
struct ril_devinfo_cbd *cbd = user_data;
struct ril_devinfo *di = cbd->di;
struct ofono_error error;
DBG_(di, "%s", di->imei);
cbd->cb(ril_error_ok(&error), di->imei, cbd->data);
}
static void ril_devinfo_query_svn_cb(gpointer user_data)
{
struct ril_devinfo_cbd *cbd = user_data;
struct ril_devinfo *di = cbd->di;
struct ofono_error error;
DBG_(di, "%s", di->imeisv);
if (di->imeisv && di->imeisv[0]) {
cbd->cb(ril_error_ok(&error), di->imeisv, cbd->data);
} else {
cbd->cb(ril_error_failure(&error), "", cbd->data);
}
}
static void ril_devinfo_query(struct ril_devinfo *di,
enum ril_devinfo_cb_tag tag, GUtilIdleFunc fn,
ofono_devinfo_query_cb_t cb, void *data)
{
GVERIFY_FALSE(gutil_idle_queue_cancel_tag(di->iq, tag));
gutil_idle_queue_add_tag_full(di->iq, tag, fn,
ril_devinfo_cbd_new(di, cb, data),
ril_devinfo_cbd_free);
}
static void ril_devinfo_query_serial(struct ofono_devinfo *info,
ofono_devinfo_query_cb_t cb,
void *data)
{
struct ril_devinfo *di = ril_devinfo_get_data(info);
DBG_(di, "");
ril_devinfo_query(di, DEVINFO_QUERY_SERIAL,
ril_devinfo_query_serial_cb, cb, data);
}
static void ril_devinfo_query_svn(struct ofono_devinfo *info,
ofono_devinfo_query_cb_t cb,
void *data)
{
struct ril_devinfo *di = ril_devinfo_get_data(info);
DBG_(di, "");
ril_devinfo_query(di, DEVINFO_QUERY_SVN,
ril_devinfo_query_svn_cb, cb, data);
}
static void ril_devinfo_register(gpointer user_data)
{
struct ril_devinfo *di = user_data;
DBG_(di, "");
ofono_devinfo_register(di->info);
}
static int ril_devinfo_probe(struct ofono_devinfo *info, unsigned int vendor,
void *data)
{
struct ril_modem *modem = data;
struct ril_devinfo *di = g_new0(struct ril_devinfo, 1);
di->log_prefix = (modem->log_prefix && modem->log_prefix[0]) ?
g_strconcat(modem->log_prefix, " ", NULL) : g_strdup("");
DBG_(di, "%s", modem->imei);
GASSERT(modem->imei);
di->q = grilio_queue_new(ril_modem_io(modem));
di->info = info;
di->imeisv = g_strdup(modem->imeisv);
di->imei = g_strdup(modem->imei);
di->iq = gutil_idle_queue_new();
gutil_idle_queue_add(di->iq, ril_devinfo_register, di);
ofono_devinfo_set_data(info, di);
return 0;
}
static void ril_devinfo_remove(struct ofono_devinfo *info)
{
struct ril_devinfo *di = ril_devinfo_get_data(info);
DBG_(di, "");
ofono_devinfo_set_data(info, NULL);
gutil_idle_queue_cancel_all(di->iq);
gutil_idle_queue_unref(di->iq);
grilio_queue_cancel_all(di->q, FALSE);
grilio_queue_unref(di->q);
g_free(di->log_prefix);
g_free(di->imeisv);
g_free(di->imei);
g_free(di);
}
const struct ofono_devinfo_driver ril_devinfo_driver = {
.name = RILMODEM_DRIVER,
.probe = ril_devinfo_probe,
.remove = ril_devinfo_remove,
/* query_revision won't be called if query_model is missing */
.query_model = ril_devinfo_query_unsupported,
.query_revision = ril_devinfo_query_revision,
.query_serial = ril_devinfo_query_serial,
.query_svn = ril_devinfo_query_svn
};
/*
* Local Variables:
* mode: C
* c-basic-offset: 8
* indent-tabs-mode: t
* End:
*/

View File

@@ -0,0 +1,258 @@
/*
* oFono - Open Source Telephony - RIL-based devices
*
* Copyright (C) 2016 Jolla Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "ril_ecclist.h"
#include "ril_log.h"
#include <gutil_strv.h>
#include <gutil_inotify.h>
#include <sys/inotify.h>
typedef GObjectClass RilEccListClass;
typedef struct ril_ecclist RilEccList;
struct ril_ecclist_priv {
struct ofono_sim *sim;
GUtilInotifyWatchCallback *dir_watch;
GUtilInotifyWatchCallback *file_watch;
char *dir;
char *path;
char *name;
};
enum ril_ecclist_signal {
SIGNAL_LIST_CHANGED,
SIGNAL_COUNT
};
#define SIGNAL_LIST_CHANGED_NAME "ril-ecclist-changed"
static guint ril_ecclist_signals[SIGNAL_COUNT] = { 0 };
G_DEFINE_TYPE(RilEccList, ril_ecclist, G_TYPE_OBJECT)
#define RIL_ECCLIST_TYPE (ril_ecclist_get_type())
#define RIL_ECCLIST(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),\
RIL_ECCLIST_TYPE, RilEccList))
static char **ril_ecclist_read(struct ril_ecclist *self)
{
struct ril_ecclist_priv *priv = self->priv;
char **list = NULL;
if (g_file_test(priv->path, G_FILE_TEST_EXISTS)) {
gsize len = 0;
gchar *content = NULL;
GError *error = NULL;
if (g_file_get_contents(priv->path, &content, &len, &error)) {
char **ptr;
DBG("%s = %s", priv->name, content);
list = g_strsplit(content, ",", 0);
for (ptr = list; *ptr; ptr++) {
*ptr = g_strstrip(*ptr);
}
gutil_strv_sort(list, TRUE);
} else if (error) {
DBG("%s: %s", priv->path, GERRMSG(error));
g_error_free(error);
}
g_free (content);
} else {
DBG("%s doesn't exist", priv->path);
}
return list;
}
static void ril_ecclist_update(struct ril_ecclist *self)
{
struct ril_ecclist_priv *priv = self->priv;
char **list = ril_ecclist_read(self);
if (!gutil_strv_equal(self->list, list)) {
DBG("%s changed", priv->name);
g_strfreev(self->list);
self->list = list;
g_signal_emit(self, ril_ecclist_signals[SIGNAL_LIST_CHANGED], 0);
} else {
g_strfreev(list);
}
}
static void ril_ecclist_changed(GUtilInotifyWatch *watch, guint mask,
guint cookie, const char *name, void *user_data)
{
struct ril_ecclist *self = RIL_ECCLIST(user_data);
struct ril_ecclist_priv *priv = self->priv;
ril_ecclist_update(self);
if (mask & IN_IGNORED) {
DBG("file %s is gone", priv->path);
gutil_inotify_watch_callback_free(priv->file_watch);
priv->file_watch = NULL;
}
}
static void ril_ecclist_dir_changed(GUtilInotifyWatch *watch, guint mask,
guint cookie, const char *name, void *user_data)
{
struct ril_ecclist *self = RIL_ECCLIST(user_data);
struct ril_ecclist_priv *priv = self->priv;
DBG("0x%04x %s", mask, name);
if (!priv->file_watch && !g_strcmp0(name, priv->name)) {
priv->file_watch = gutil_inotify_watch_callback_new(priv->path,
IN_MODIFY | IN_CLOSE_WRITE,
ril_ecclist_changed, self);
if (priv->file_watch) {
DBG("watching %s", priv->path);
ril_ecclist_update(self);
}
}
if (mask & IN_IGNORED) {
DBG("%s is gone", priv->dir);
gutil_inotify_watch_callback_free(priv->dir_watch);
priv->dir_watch = NULL;
}
}
gulong ril_ecclist_add_list_changed_handler(struct ril_ecclist *self,
ril_ecclist_cb_t cb, void *arg)
{
return (G_LIKELY(self) && G_LIKELY(cb)) ? g_signal_connect(self,
SIGNAL_LIST_CHANGED_NAME, G_CALLBACK(cb), arg) : 0;
}
void ril_ecclist_remove_handler(struct ril_ecclist *self, gulong id)
{
if (G_LIKELY(self) && G_LIKELY(id)) {
g_signal_handler_disconnect(self, id);
}
}
struct ril_ecclist *ril_ecclist_new(const char *path)
{
if (path) {
struct ril_ecclist *self = g_object_new(RIL_ECCLIST_TYPE, 0);
struct ril_ecclist_priv *priv = self->priv;
DBG("%s", path);
priv->path = g_strdup(path);
priv->name = g_path_get_basename(path);
priv->dir = g_path_get_dirname(path);
priv->dir_watch = gutil_inotify_watch_callback_new(priv->dir,
IN_MODIFY|IN_MOVED_FROM|IN_MOVED_TO|IN_DELETE|
IN_CREATE|IN_DELETE_SELF|IN_CLOSE_WRITE,
ril_ecclist_dir_changed, self);
if (priv->dir_watch) {
DBG("watching %s", priv->dir);
}
self->list = ril_ecclist_read(self);
priv->file_watch = gutil_inotify_watch_callback_new(priv->path,
IN_MODIFY | IN_CLOSE_WRITE,
ril_ecclist_changed, self);
if (priv->file_watch) {
DBG("watching %s", priv->path);
}
return self;
}
return NULL;
}
struct ril_ecclist *ril_ecclist_ref(struct ril_ecclist *self)
{
if (G_LIKELY(self)) {
g_object_ref(RIL_ECCLIST(self));
return self;
} else {
return NULL;
}
}
void ril_ecclist_unref(struct ril_ecclist *self)
{
if (G_LIKELY(self)) {
g_object_unref(RIL_ECCLIST(self));
}
}
static void ril_ecclist_init(struct ril_ecclist *self)
{
self->priv = G_TYPE_INSTANCE_GET_PRIVATE(self, RIL_ECCLIST_TYPE,
struct ril_ecclist_priv);
}
static void ril_ecclist_dispose(GObject *object)
{
struct ril_ecclist *self = RIL_ECCLIST(object);
struct ril_ecclist_priv *priv = self->priv;
if (priv->dir_watch) {
gutil_inotify_watch_callback_free(priv->dir_watch);
priv->dir_watch = NULL;
}
if (priv->file_watch) {
gutil_inotify_watch_callback_free(priv->file_watch);
priv->file_watch = NULL;
}
G_OBJECT_CLASS(ril_ecclist_parent_class)->dispose(object);
}
static void ril_ecclist_finalize(GObject *object)
{
struct ril_ecclist *self = RIL_ECCLIST(object);
struct ril_ecclist_priv *priv = self->priv;
GASSERT(!priv->dir_watch);
GASSERT(!priv->file_watch);
g_free(priv->dir);
g_free(priv->path);
g_free(priv->name);
g_strfreev(self->list);
G_OBJECT_CLASS(ril_ecclist_parent_class)->finalize(object);
}
static void ril_ecclist_class_init(RilEccListClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS(klass);
object_class->dispose = ril_ecclist_dispose;
object_class->finalize = ril_ecclist_finalize;
g_type_class_add_private(klass, sizeof(struct ril_ecclist_priv));
ril_ecclist_signals[SIGNAL_LIST_CHANGED] =
g_signal_new(SIGNAL_LIST_CHANGED_NAME,
G_OBJECT_CLASS_TYPE(klass), G_SIGNAL_RUN_FIRST,
0, NULL, NULL, NULL, G_TYPE_NONE, 0);
}
/*
* Local Variables:
* mode: C
* c-basic-offset: 8
* indent-tabs-mode: t
* End:
*/

View File

@@ -0,0 +1,46 @@
/*
* oFono - Open Source Telephony - RIL-based devices
*
* Copyright (C) 2016 Jolla Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#ifndef RIL_ECCLIST_H
#define RIL_ECCLIST_H
#include "ril_types.h"
struct ril_ecclist_priv;
struct ril_ecclist {
GObject object;
struct ril_ecclist_priv *priv;
char **list;
};
typedef void (*ril_ecclist_cb_t)(struct ril_ecclist *ecc, void *arg);
struct ril_ecclist *ril_ecclist_new(const char *path);
struct ril_ecclist *ril_ecclist_ref(struct ril_ecclist *ecc);
void ril_ecclist_unref(struct ril_ecclist *ecc);
gulong ril_ecclist_add_list_changed_handler(struct ril_ecclist *ecc,
ril_ecclist_cb_t cb, void *arg);
void ril_ecclist_remove_handler(struct ril_ecclist *ecc, gulong id);
#endif /* RIL_ECCLIST_H */
/*
* Local Variables:
* mode: C
* c-basic-offset: 8
* indent-tabs-mode: t
* End:
*/

View File

@@ -0,0 +1,283 @@
/*
* oFono - Open Source Telephony - RIL-based devices
*
* Copyright (C) 2015-2016 Jolla Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "ril_plugin.h"
#include "ril_network.h"
#include "ril_data.h"
#include "ril_util.h"
#include "ril_log.h"
#include "common.h"
/*
* This module is the ofono_gprs_driver implementation for rilmodem.
*
* Notes:
*
* 1. ofono_gprs_suspend/resume() are not used by this module, as
* the concept of suspended GPRS is not exposed by RILD.
*
* 2. ofono_gprs_bearer_notify() is never called as RILD does not
* expose an unsolicited event equivalent to +CPSB ( see 27.007
* 7.29 ), and the tech values returned by REQUEST_DATA/VOICE
* _REGISTRATION requests do not match the values defined for
* <AcT> in the +CPSB definition. Note, the values returned by
* the *REGISTRATION commands are aligned with those defined by
* +CREG ( see 27.003 7.2 ).
*/
struct ril_gprs {
struct ofono_gprs *gprs;
struct ril_modem *md;
struct ril_data *data;
struct ril_network *network;
GRilIoChannel *io;
GRilIoQueue *q;
gboolean attached;
int max_cids;
enum network_registration_status registration_status;
guint register_id;
gulong network_event_id;
gulong data_event_id;
guint set_attached_id;
};
struct ril_gprs_cbd {
struct ril_gprs *gd;
ofono_gprs_cb_t cb;
gpointer data;
};
#define ril_gprs_cbd_free g_free
static struct ril_gprs *ril_gprs_get_data(struct ofono_gprs *ofono)
{
return ofono ? ofono_gprs_get_data(ofono) : NULL;
}
static struct ril_gprs_cbd *ril_gprs_cbd_new(struct ril_gprs *gd,
ofono_gprs_cb_t cb, void *data)
{
struct ril_gprs_cbd *cbd = g_new0(struct ril_gprs_cbd, 1);
cbd->gd = gd;
cbd->cb = cb;
cbd->data = data;
return cbd;
}
static enum network_registration_status ril_gprs_fix_registration_status(
struct ril_gprs *gd, enum network_registration_status status)
{
if (!ril_data_allowed(gd->data)) {
return NETWORK_REGISTRATION_STATUS_NOT_REGISTERED;
} else {
/* TODO: need a way to make sure that SPDI information has
* already been read from the SIM (i.e. sim_spdi_read_cb in
* network.c has been called) */
struct ofono_netreg *netreg = ril_modem_ofono_netreg(gd->md);
return ril_netreg_check_if_really_roaming(netreg, status);
}
}
static void ril_gprs_data_update_registration_state(struct ril_gprs *gd)
{
const enum network_registration_status status =
ril_gprs_fix_registration_status(gd, gd->network->data.status);
if (gd->registration_status != status) {
ofono_info("data reg changed %d -> %d (%s), attached %d",
gd->registration_status, status,
registration_status_to_string(status),
gd->attached);
gd->registration_status = status;
ofono_gprs_status_notify(gd->gprs, gd->registration_status);
}
}
static void ril_gprs_check_data_allowed(struct ril_gprs *gd)
{
DBG("%s %d %d", ril_modem_get_path(gd->md), ril_data_allowed(gd->data),
gd->attached);
if (!ril_data_allowed(gd->data) && gd->attached) {
gd->attached = FALSE;
if (gd->gprs) {
ofono_gprs_detached_notify(gd->gprs);
}
}
ril_gprs_data_update_registration_state(gd);
}
static gboolean ril_gprs_set_attached_cb(gpointer user_data)
{
struct ofono_error error;
struct ril_gprs_cbd *cbd = user_data;
struct ril_gprs *gd = cbd->gd;
GASSERT(gd->set_attached_id);
gd->set_attached_id = 0;
ril_gprs_check_data_allowed(gd);
cbd->cb(ril_error_ok(&error), cbd->data);
return FALSE;
}
static void ril_gprs_set_attached(struct ofono_gprs *gprs, int attached,
ofono_gprs_cb_t cb, void *data)
{
struct ril_gprs *gd = ril_gprs_get_data(gprs);
if (ril_data_allowed(gd->data) || !attached) {
DBG("%s attached: %d", ril_modem_get_path(gd->md), attached);
if (gd->set_attached_id) {
g_source_remove(gd->set_attached_id);
}
gd->attached = attached;
gd->set_attached_id = g_idle_add_full(G_PRIORITY_DEFAULT_IDLE,
ril_gprs_set_attached_cb,
ril_gprs_cbd_new(gd, cb, data),
ril_gprs_cbd_free);
} else {
struct ofono_error error;
DBG("%s not allowed to attach", ril_modem_get_path(gd->md));
cb(ril_error_failure(&error), data);
}
}
static void ril_gprs_allow_data_changed(struct ril_data *data, void *user_data)
{
struct ril_gprs *gd = user_data;
GASSERT(gd->data == data);
DBG("%s %d", ril_modem_get_path(gd->md), ril_data_allowed(data));
if (!gd->set_attached_id) {
ril_gprs_check_data_allowed(gd);
}
}
static void ril_gprs_data_registration_state_changed(struct ril_network *net,
void *user_data)
{
struct ril_gprs *gd = user_data;
const struct ril_registration_state *data = &net->data;
GASSERT(gd->network == net);
if (data->max_calls > gd->max_cids) {
DBG("Setting max cids to %d", data->max_calls);
gd->max_cids = data->max_calls;
ofono_gprs_set_cid_range(gd->gprs, 1, gd->max_cids);
}
ril_gprs_data_update_registration_state(gd);
}
static void ril_gprs_registration_status(struct ofono_gprs *gprs,
ofono_gprs_status_cb_t cb, void *data)
{
struct ril_gprs *gd = ril_gprs_get_data(gprs);
struct ofono_error error;
const enum network_registration_status status = gd->attached ?
gd->registration_status :
NETWORK_REGISTRATION_STATUS_NOT_REGISTERED;
DBG("%d (%s)", status, registration_status_to_string(status));
cb(ril_error_ok(&error), status, data);
}
static gboolean ril_gprs_register(gpointer user_data)
{
struct ril_gprs *gd = user_data;
gd->register_id = 0;
gd->network_event_id = ril_network_add_data_state_changed_handler(
gd->network, ril_gprs_data_registration_state_changed, gd);
gd->data_event_id = ril_data_add_allow_changed_handler(gd->data,
ril_gprs_allow_data_changed, gd);
gd->registration_status = ril_gprs_fix_registration_status(gd,
gd->network->data.status);
gd->max_cids = gd->network->data.max_calls;
if (gd->max_cids > 0) {
DBG("Setting max cids to %d", gd->max_cids);
ofono_gprs_set_cid_range(gd->gprs, 1, gd->max_cids);
}
ofono_gprs_register(gd->gprs);
return FALSE;
}
static int ril_gprs_probe(struct ofono_gprs *gprs, unsigned int vendor,
void *data)
{
struct ril_modem *modem = data;
struct ril_gprs *gd = g_new0(struct ril_gprs, 1);
DBG("%s", ril_modem_get_path(modem));
gd->md = modem;
gd->io = grilio_channel_ref(ril_modem_io(modem));
gd->q = grilio_queue_new(gd->io);
gd->data = ril_data_ref(modem->data);
gd->network = ril_network_ref(modem->network);
gd->gprs = gprs;
ofono_gprs_set_data(gprs, gd);
/* ofono crashes if we register right away */
gd->register_id = g_idle_add(ril_gprs_register, gd);
return 0;
}
static void ril_gprs_remove(struct ofono_gprs *gprs)
{
struct ril_gprs *gd = ril_gprs_get_data(gprs);
DBG("%s", ril_modem_get_path(gd->md));
ofono_gprs_set_data(gprs, NULL);
if (gd->set_attached_id) {
g_source_remove(gd->set_attached_id);
}
if (gd->register_id) {
g_source_remove(gd->register_id);
}
ril_network_remove_handler(gd->network, gd->network_event_id);
ril_network_unref(gd->network);
ril_data_remove_handler(gd->data, gd->data_event_id);
ril_data_unref(gd->data);
grilio_channel_unref(gd->io);
grilio_queue_cancel_all(gd->q, FALSE);
grilio_queue_unref(gd->q);
g_free(gd);
}
const struct ofono_gprs_driver ril_gprs_driver = {
.name = RILMODEM_DRIVER,
.probe = ril_gprs_probe,
.remove = ril_gprs_remove,
.set_attached = ril_gprs_set_attached,
.attached_status = ril_gprs_registration_status,
};
/*
* Local Variables:
* mode: C
* c-basic-offset: 8
* indent-tabs-mode: t
* End:
*/

View File

@@ -0,0 +1,598 @@
/*
* oFono - Open Source Telephony - RIL-based devices
*
* Copyright (C) 2015-2017 Jolla Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "ril_plugin.h"
#include "ril_network.h"
#include "ril_data.h"
#include "ril_util.h"
#include "ril_log.h"
#include <gutil_strv.h>
#include <arpa/inet.h>
#include "ofono.h"
#include "common.h"
#include "mtu-watch.h"
#define CTX_ID_NONE ((unsigned int)(-1))
#define MAX_MTU 1280
struct ril_gprs_context_call {
struct ril_data_request *req;
ofono_gprs_context_cb_t cb;
gpointer data;
};
struct ril_gprs_context {
struct ofono_gprs_context *gc;
struct ril_modem *modem;
struct ril_network *network;
struct ril_data *data;
guint active_ctx_cid;
gulong calls_changed_id;
struct mtu_watch *mtu_watch;
struct ril_data_call *active_call;
struct ril_gprs_context_call activate;
struct ril_gprs_context_call deactivate;
};
static inline struct ril_gprs_context *ril_gprs_context_get_data(
struct ofono_gprs_context *gprs)
{
return ofono_gprs_context_get_data(gprs);
}
static char *ril_gprs_context_netmask(const char *bits)
{
if (bits) {
int nbits = atoi(bits);
if (nbits > 0 && nbits < 33) {
const char* str;
struct in_addr in;
in.s_addr = htonl((nbits == 32) ? 0xffffffff :
((1u << nbits)-1) << (32-nbits));
str = inet_ntoa(in);
if (str) {
return g_strdup(str);
}
}
}
return NULL;
}
static int ril_gprs_context_address_family(const char *addr)
{
if (strchr(addr, ':')) {
return AF_INET6;
} else if (strchr(addr, '.')) {
return AF_INET;
} else {
return AF_UNSPEC;
}
}
static void ril_gprs_context_free_active_call(struct ril_gprs_context *gcd)
{
if (gcd->active_call) {
ril_data_call_free(gcd->active_call);
gcd->active_call = NULL;
}
if (gcd->calls_changed_id) {
ril_data_remove_handler(gcd->data, gcd->calls_changed_id);
gcd->calls_changed_id = 0;
}
if (gcd->mtu_watch) {
mtu_watch_free(gcd->mtu_watch);
gcd->mtu_watch = NULL;
}
}
static void ril_gprs_context_set_active_call(struct ril_gprs_context *gcd,
const struct ril_data_call *call)
{
if (call) {
ril_data_call_free(gcd->active_call);
gcd->active_call = ril_data_call_dup(call);
if (!gcd->mtu_watch) {
gcd->mtu_watch = mtu_watch_new(MAX_MTU);
}
mtu_watch_set_ifname(gcd->mtu_watch, call->ifname);
} else {
ril_gprs_context_free_active_call(gcd);
}
}
static void ril_gprs_context_set_disconnected(struct ril_gprs_context *gcd)
{
if (gcd->active_call) {
ril_gprs_context_free_active_call(gcd);
if (gcd->deactivate.req) {
struct ril_gprs_context_call deact = gcd->deactivate;
/*
* Complete the deactivate request. We need to
* clear gcd->deactivate first because cancelling
* the deactivation request will probably result
* in ril_gprs_context_deactivate_primary_cb() being
* invoked with GRILIO_CANCELLED status. And we don't
* want to fail the disconnect request because this
* is a success (we wanted to disconnect the data
* call and it's gone).
*
* Additionally, we need to make sure that we don't
* complete the same request twice - that would crash
* the core.
*/
memset(&gcd->deactivate, 0, sizeof(gcd->deactivate));
ril_data_request_cancel(deact.req);
if (deact.cb) {
struct ofono_error error;
ofono_info("Deactivated data call");
deact.cb(ril_error_ok(&error), deact.data);
}
}
}
if (gcd->active_ctx_cid != CTX_ID_NONE) {
guint id = gcd->active_ctx_cid;
gcd->active_ctx_cid = CTX_ID_NONE;
DBG("ofono context %u deactivated", id);
ofono_gprs_context_deactivated(gcd->gc, id);
}
}
static void ril_gprs_context_set_address(struct ofono_gprs_context *gc,
const struct ril_data_call *call)
{
const char *ip_addr = NULL;
char *ip_mask = NULL;
const char *ipv6_addr = NULL;
unsigned char ipv6_prefix_length = 0;
char *tmp_ip_addr = NULL;
char *tmp_ipv6_addr = NULL;
char * const *list = call->addresses;
const int n = gutil_strv_length(list);
int i;
for (i = 0; i < n && (!ipv6_addr || !ip_addr); i++) {
const char *addr = list[i];
switch (ril_gprs_context_address_family(addr)) {
case AF_INET:
if (!ip_addr) {
const char* s = strstr(addr, "/");
if (s) {
const gsize len = s - addr;
tmp_ip_addr = g_strndup(addr, len);
ip_addr = tmp_ip_addr;
ip_mask = ril_gprs_context_netmask(s+1);
} else {
ip_addr = addr;
}
if (!ip_mask) {
ip_mask = g_strdup("255.255.255.0");
}
}
break;
case AF_INET6:
if (!ipv6_addr) {
const char* s = strstr(addr, "/");
if (s) {
const gsize len = s - addr;
const int prefix = atoi(s + 1);
tmp_ipv6_addr = g_strndup(addr, len);
ipv6_addr = tmp_ipv6_addr;
if (prefix >= 0 && prefix <= 128) {
ipv6_prefix_length = prefix;
}
} else {
ipv6_addr = addr;
}
}
}
}
ofono_gprs_context_set_ipv4_address(gc, ip_addr, TRUE);
ofono_gprs_context_set_ipv4_netmask(gc, ip_mask);
ofono_gprs_context_set_ipv6_address(gc, ipv6_addr);
ofono_gprs_context_set_ipv6_prefix_length(gc, ipv6_prefix_length);
if (!ip_addr && !ipv6_addr) {
ofono_error("GPRS context: No IP address");
}
/* Allocate temporary strings */
g_free(ip_mask);
g_free(tmp_ip_addr);
g_free(tmp_ipv6_addr);
}
static void ril_gprs_context_set_gateway(struct ofono_gprs_context *gc,
const struct ril_data_call *call)
{
const char *ip_gw = NULL;
const char *ipv6_gw = NULL;
char * const *list = call->gateways;
const int n = gutil_strv_length(list);
int i;
/* Pick 1 gw for each protocol*/
for (i = 0; i < n && (!ipv6_gw || !ip_gw); i++) {
const char *addr = list[i];
switch (ril_gprs_context_address_family(addr)) {
case AF_INET:
if (!ip_gw) ip_gw = addr;
break;
case AF_INET6:
if (!ipv6_gw) ipv6_gw = addr;
break;
}
}
ofono_gprs_context_set_ipv4_gateway(gc, ip_gw);
ofono_gprs_context_set_ipv6_gateway(gc, ipv6_gw);
}
static void ril_gprs_context_set_dns_servers(struct ofono_gprs_context *gc,
const struct ril_data_call *call)
{
int i;
char * const *list = call->dnses;
const int n = gutil_strv_length(list);
const char **ip_dns = g_new0(const char *, n+1);
const char **ipv6_dns = g_new0(const char *, n+1);
const char **ip_ptr = ip_dns;
const char **ipv6_ptr = ipv6_dns;
for (i = 0; i < n; i++) {
const char *addr = list[i];
switch (ril_gprs_context_address_family(addr)) {
case AF_INET:
*ip_ptr++ = addr;
break;
case AF_INET6:
*ipv6_ptr++ = addr;
break;
}
}
ofono_gprs_context_set_ipv4_dns_servers(gc, ip_dns);
ofono_gprs_context_set_ipv6_dns_servers(gc, ipv6_dns);
g_free(ip_dns);
g_free(ipv6_dns);
}
/* Only compares the stuff that's important to us */
#define DATA_CALL_IFNAME_CHANGED (0x01)
#define DATA_CALL_ADDRESS_CHANGED (0x02)
#define DATA_CALL_GATEWAY_CHANGED (0x04)
#define DATA_CALL_DNS_CHANGED (0x08)
#define DATA_CALL_ALL_CHANGED (0x0f)
static int ril_gprs_context_data_call_change(
const struct ril_data_call *c1,
const struct ril_data_call *c2)
{
if (!c1 && !c2) {
return 0;
} else if (c1 && c2) {
int changes = 0;
if (g_strcmp0(c1->ifname, c2->ifname)) {
changes |= DATA_CALL_IFNAME_CHANGED;
}
if (!gutil_strv_equal(c1->addresses, c2->addresses)) {
changes |= DATA_CALL_ADDRESS_CHANGED;
}
if (!gutil_strv_equal(c1->gateways, c2->gateways)) {
changes |= DATA_CALL_GATEWAY_CHANGED;
}
if (!gutil_strv_equal(c1->dnses, c2->dnses)) {
changes |= DATA_CALL_DNS_CHANGED;
}
return changes;
} else {
return DATA_CALL_ALL_CHANGED;
}
}
static void ril_gprs_context_call_list_changed(struct ril_data *data, void *arg)
{
struct ril_gprs_context *gcd = arg;
struct ofono_gprs_context *gc = gcd->gc;
/*
* gcd->active_call can't be NULL here because this callback
* is only registered when we have the active call and released
* when active call is dropped.
*/
struct ril_data_call *prev_call = gcd->active_call;
const struct ril_data_call *call =
ril_data_call_find(data->data_calls, prev_call->cid);
int change = 0;
if (call && call->active != RIL_DATA_CALL_INACTIVE) {
/* Compare it against the last known state */
change = ril_gprs_context_data_call_change(call, prev_call);
} else {
ofono_error("Clearing active context");
ril_gprs_context_set_disconnected(gcd);
call = NULL;
}
if (!call) {
/* We are not interested */
return;
} else if (!change) {
DBG("call %u didn't change", call->cid);
return;
} else {
DBG("call %u changed", call->cid);
}
/*
* prev_call points to the previous active call, and it will
* be deallocated at the end of the this function. Clear the
* gcd->active_call pointer so that we don't deallocate it twice.
*/
gcd->active_call = NULL;
ril_gprs_context_set_active_call(gcd, call);
if (call->status != PDP_FAIL_NONE) {
ofono_info("data call status: %d", call->status);
}
if (change & DATA_CALL_IFNAME_CHANGED) {
DBG("interface changed");
ofono_gprs_context_set_interface(gc, call->ifname);
}
if (change & DATA_CALL_ADDRESS_CHANGED) {
DBG("address changed");
ril_gprs_context_set_address(gc, call);
}
if (change & DATA_CALL_GATEWAY_CHANGED) {
DBG("gateway changed");
ril_gprs_context_set_gateway(gc, call);
}
if (change & DATA_CALL_DNS_CHANGED) {
DBG("name server(s) changed");
ril_gprs_context_set_dns_servers(gc, call);
}
ofono_gprs_context_signal_change(gc, call->cid);
ril_data_call_free(prev_call);
}
static void ril_gprs_context_activate_primary_cb(struct ril_data *data,
int ril_status, const struct ril_data_call *call,
void *user_data)
{
struct ril_gprs_context *gcd = user_data;
struct ofono_gprs_context *gc = gcd->gc;
struct ofono_error error;
ofono_gprs_context_cb_t cb;
gpointer cb_data;
ril_error_init_failure(&error);
if (ril_status != RIL_E_SUCCESS) {
ofono_error("GPRS context: Reply failure: %s",
ril_error_to_string(ril_status));
} else if (call->status != PDP_FAIL_NONE) {
ofono_error("Unexpected data call status %d", call->status);
error.type = OFONO_ERROR_TYPE_CMS;
error.error = call->status;
} else if (!call->ifname) {
/* Must have interface */
ofono_error("GPRS context: No interface");
} else {
ofono_info("setting up data call");
GASSERT(!gcd->calls_changed_id);
ril_data_remove_handler(gcd->data, gcd->calls_changed_id);
gcd->calls_changed_id =
ril_data_add_calls_changed_handler(gcd->data,
ril_gprs_context_call_list_changed, gcd);
ril_gprs_context_set_active_call(gcd, call);
ofono_gprs_context_set_interface(gc, call->ifname);
ril_gprs_context_set_address(gc, call);
ril_gprs_context_set_gateway(gc, call);
ril_gprs_context_set_dns_servers(gc, call);
ril_error_init_ok(&error);
}
if (error.type != OFONO_ERROR_TYPE_NO_ERROR) {
gcd->active_ctx_cid = CTX_ID_NONE;
}
cb = gcd->activate.cb;
cb_data = gcd->activate.data;
GASSERT(gcd->activate.req);
memset(&gcd->activate, 0, sizeof(gcd->activate));
if (cb) {
cb(&error, cb_data);
}
}
static void ril_gprs_context_activate_primary(struct ofono_gprs_context *gc,
const struct ofono_gprs_primary_context *ctx,
ofono_gprs_context_cb_t cb, void *data)
{
struct ril_gprs_context *gcd = ril_gprs_context_get_data(gc);
struct ofono_netreg *netreg = ril_modem_ofono_netreg(gcd->modem);
const int rs = ofono_netreg_get_status(netreg);
/* Let's make sure that we aren't connecting when roaming not allowed */
if (rs == NETWORK_REGISTRATION_STATUS_ROAMING) {
struct ofono_gprs *gprs = ril_modem_ofono_gprs(gcd->modem);
if (!__ofono_gprs_get_roaming_allowed(gprs) &&
ril_netreg_check_if_really_roaming(netreg, rs) ==
NETWORK_REGISTRATION_STATUS_ROAMING) {
struct ofono_error error;
ofono_info("Can't activate context %u (roaming)",
ctx->cid);
cb(ril_error_failure(&error), data);
return;
}
}
ofono_info("Activating context: %u", ctx->cid);
GASSERT(!gcd->activate.req);
GASSERT(ctx->cid != CTX_ID_NONE);
gcd->active_ctx_cid = ctx->cid;
gcd->activate.cb = cb;
gcd->activate.data = data;
gcd->activate.req = ril_data_call_setup(gcd->data, ctx,
ril_gprs_context_activate_primary_cb, gcd);
}
static void ril_gprs_context_deactivate_primary_cb(struct ril_data *data,
int ril_status, void *user_data)
{
struct ril_gprs_context *gcd = user_data;
/*
* Data call list may change before the completion of the deactivate
* request, in that case ril_gprs_context_set_disconnected will be
* invoked and gcd->deactivate.req will be NULL.
*/
if (gcd->deactivate.req) {
struct ofono_error error;
ofono_gprs_context_cb_t cb = gcd->deactivate.cb;
gpointer cb_data = gcd->deactivate.data;
if (ril_status == RIL_E_SUCCESS) {
GASSERT(gcd->active_call);
ril_error_init_ok(&error);
ofono_info("Deactivated data call");
} else {
ril_error_init_failure(&error);
ofono_error("Deactivate failure: %s",
ril_error_to_string(ril_status));
}
memset(&gcd->deactivate, 0, sizeof(gcd->deactivate));
if (cb) {
ril_gprs_context_free_active_call(gcd);
cb(&error, cb_data);
return;
}
}
/* Make sure we are in the disconnected state */
ril_gprs_context_set_disconnected(gcd);
}
static void ril_gprs_context_deactivate_primary(struct ofono_gprs_context *gc,
unsigned int id, ofono_gprs_context_cb_t cb, void *data)
{
struct ril_gprs_context *gcd = ril_gprs_context_get_data(gc);
GASSERT(gcd->active_call && gcd->active_ctx_cid == id);
ofono_info("Deactivating context: %u", id);
if (gcd->active_call && gcd->active_ctx_cid == id) {
gcd->deactivate.cb = cb;
gcd->deactivate.data = data;
gcd->deactivate.req = ril_data_call_deactivate(gcd->data,
gcd->active_call->cid,
ril_gprs_context_deactivate_primary_cb, gcd);
} else if (cb) {
struct ofono_error error;
cb(ril_error_ok(&error), data);
}
}
static void ril_gprs_context_detach_shutdown(struct ofono_gprs_context *gc,
unsigned int id)
{
DBG("%u", id);
ril_gprs_context_deactivate_primary(gc, id, NULL, NULL);
}
static int ril_gprs_context_probe(struct ofono_gprs_context *gc,
unsigned int vendor, void *data)
{
struct ril_modem *modem = data;
struct ril_gprs_context *gcd = g_new0(struct ril_gprs_context, 1);
DBG("");
gcd->gc = gc;
gcd->modem = modem;
gcd->network = ril_network_ref(modem->network);
gcd->data = ril_data_ref(modem->data);
gcd->active_ctx_cid = CTX_ID_NONE;
ofono_gprs_context_set_data(gc, gcd);
return 0;
}
static void ril_gprs_context_remove(struct ofono_gprs_context *gc)
{
struct ril_gprs_context *gcd = ril_gprs_context_get_data(gc);
DBG("");
ofono_gprs_context_set_data(gc, NULL);
if (gcd->activate.req) {
/*
* The core has already completed its pending D-Bus
* request, invoking the completion callback will
* cause libdbus to panic.
*/
ril_data_request_detach(gcd->activate.req);
ril_data_request_cancel(gcd->activate.req);
}
if (gcd->deactivate.req) {
/* Let it complete but we won't be around to be notified. */
ril_data_request_detach(gcd->deactivate.req);
} else if (gcd->active_call) {
ril_data_call_deactivate(gcd->data, gcd->active_call->cid,
NULL, NULL);
}
ril_data_remove_handler(gcd->data, gcd->calls_changed_id);
ril_data_unref(gcd->data);
ril_network_unref(gcd->network);
ril_data_call_free(gcd->active_call);
mtu_watch_free(gcd->mtu_watch);
g_free(gcd);
}
const struct ofono_gprs_context_driver ril_gprs_context_driver = {
.name = RILMODEM_DRIVER,
.probe = ril_gprs_context_probe,
.remove = ril_gprs_context_remove,
.activate_primary = ril_gprs_context_activate_primary,
.deactivate_primary = ril_gprs_context_deactivate_primary,
.detach_shutdown = ril_gprs_context_detach_shutdown,
};
/*
* Local Variables:
* mode: C
* c-basic-offset: 8
* indent-tabs-mode: t
* End:
*/

View File

@@ -0,0 +1,31 @@
/*
* oFono - Open Source Telephony - RIL-based devices
*
* Copyright (C) 2015 Jolla Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#ifndef RIL_LOG_H
#define RIL_LOG_H
#define GLOG_MODULE_NAME ril_log
#include <gutil_log.h>
#include <ofono/log.h>
#endif /* RIL_LOG_H */
/*
* Local Variables:
* mode: C
* c-basic-offset: 8
* indent-tabs-mode: t
* End:
*/

View File

@@ -0,0 +1,513 @@
/*
* oFono - Open Source Telephony - RIL-based devices
*
* Copyright (C) 2015-2017 Jolla Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "ril_plugin.h"
#include "ril_network.h"
#include "ril_radio.h"
#include "ril_sim_card.h"
#include "ril_sim_settings.h"
#include "ril_cell_info.h"
#include "ril_data.h"
#include "ril_util.h"
#include "ril_log.h"
#include "ofono.h"
#include "sailfish_watch.h"
#define MAX_PDP_CONTEXTS (2)
#define ONLINE_TIMEOUT_SECS (15) /* 20 sec is hardcoded in ofono core */
enum ril_modem_power_state {
POWERED_OFF,
POWERED_ON,
POWERING_OFF
};
enum ril_modem_online_state {
OFFLINE,
GOING_ONLINE,
ONLINE,
GOING_OFFLINE
};
struct ril_modem_online_request {
ofono_modem_online_cb_t cb;
struct ril_modem_data *md;
void *data;
guint timeout_id;
};
struct ril_modem_data {
struct ril_modem modem;
struct sailfish_watch *watch;
GRilIoQueue *q;
char *log_prefix;
char *imeisv;
char *imei;
char *ecclist_file;
gulong imsi_event_id;
guint online_check_id;
enum ril_modem_power_state power_state;
gulong radio_state_event_id;
struct ril_modem_online_request set_online;
struct ril_modem_online_request set_offline;
};
#define RADIO_POWER_TAG(md) (md)
#define DBG_(md,fmt,args...) DBG("%s" fmt, (md)->log_prefix, ##args)
static struct ril_modem_data *ril_modem_data_from_ofono(struct ofono_modem *o)
{
struct ril_modem_data *md = ofono_modem_get_data(o);
GASSERT(md->modem.ofono == o);
return md;
}
static void *ril_modem_get_atom_data(struct ril_modem *modem,
enum ofono_atom_type type)
{
if (modem && modem->ofono) {
struct ofono_atom *atom =
__ofono_modem_find_atom(modem->ofono, type);
if (atom) {
return __ofono_atom_get_data(atom);
}
}
return NULL;
}
struct ofono_sim *ril_modem_ofono_sim(struct ril_modem *modem)
{
return ril_modem_get_atom_data(modem, OFONO_ATOM_TYPE_SIM);
}
struct ofono_gprs *ril_modem_ofono_gprs(struct ril_modem *modem)
{
return ril_modem_get_atom_data(modem, OFONO_ATOM_TYPE_GPRS);
}
struct ofono_netreg *ril_modem_ofono_netreg(struct ril_modem *modem)
{
return ril_modem_get_atom_data(modem, OFONO_ATOM_TYPE_NETREG);
}
static inline struct ofono_radio_settings *ril_modem_radio_settings(
struct ril_modem *modem)
{
return ril_modem_get_atom_data(modem, OFONO_ATOM_TYPE_RADIO_SETTINGS);
}
void ril_modem_delete(struct ril_modem *md)
{
if (md && md->ofono) {
ofono_modem_remove(md->ofono);
}
}
static void ril_modem_online_request_ok(struct ril_modem_online_request *req)
{
if (req->timeout_id) {
g_source_remove(req->timeout_id);
req->timeout_id = 0;
}
if (req->cb) {
struct ofono_error error;
ofono_modem_online_cb_t cb = req->cb;
void *data = req->data;
req->cb = NULL;
req->data = NULL;
cb(ril_error_ok(&error), data);
}
}
static void ril_modem_update_online_state(struct ril_modem_data *md)
{
switch (md->modem.radio->state) {
case RADIO_STATE_ON:
DBG("online");
ril_modem_online_request_ok(&md->set_online);
break;
case RADIO_STATE_OFF:
case RADIO_STATE_UNAVAILABLE:
DBG("offline");
ril_modem_online_request_ok(&md->set_offline);
break;
default:
break;
}
if (!md->set_offline.timeout_id && !md->set_online.timeout_id &&
md->power_state == POWERING_OFF) {
md->power_state = POWERED_OFF;
if (md->modem.ofono) {
ofono_modem_set_powered(md->modem.ofono, FALSE);
}
}
}
static gboolean ril_modem_online_request_timeout(gpointer data)
{
struct ril_modem_online_request *req = data;
struct ofono_error error;
ofono_modem_online_cb_t cb = req->cb;
void *cb_data = req->data;
GASSERT(req->timeout_id);
GASSERT(cb);
req->timeout_id = 0;
req->cb = NULL;
req->data = NULL;
cb(ril_error_failure(&error), cb_data);
ril_modem_update_online_state(req->md);
return G_SOURCE_REMOVE;
}
static gboolean ril_modem_online_check(gpointer data)
{
struct ril_modem_data *md = data;
GASSERT(md->online_check_id);
md->online_check_id = 0;
ril_modem_update_online_state(md);
return FALSE;
}
static void ril_modem_schedule_online_check(struct ril_modem_data *md)
{
if (!md->online_check_id) {
md->online_check_id = g_idle_add(ril_modem_online_check, md);
}
}
static void ril_modem_update_radio_settings(struct ril_modem_data *md)
{
struct ril_modem *m = &md->modem;
if (m->radio->state == RADIO_STATE_ON && md->watch->imsi) {
/* radio-settings.c assumes that IMSI is available */
if (!ril_modem_radio_settings(m)) {
DBG_(md, "initializing radio settings interface");
ofono_radio_settings_create(m->ofono, 0,
RILMODEM_DRIVER, md);
}
} else {
/* ofono core may remove radio settings atom internally */
struct ofono_radio_settings *rs = ril_modem_radio_settings(m);
if (rs) {
DBG_(md, "removing radio settings interface");
ofono_radio_settings_remove(rs);
} else {
DBG_(md, "radio settings interface is already gone");
}
}
}
static void ril_modem_radio_state_cb(struct ril_radio *radio, void *data)
{
struct ril_modem_data *md = data;
GASSERT(md->modem.radio == radio);
ril_modem_update_radio_settings(md);
ril_modem_update_online_state(md);
}
static void ril_modem_imsi_cb(struct sailfish_watch *watch, void *data)
{
struct ril_modem_data *md = data;
GASSERT(md->watch == watch);
ril_modem_update_radio_settings(md);
}
static void ril_modem_pre_sim(struct ofono_modem *modem)
{
struct ril_modem_data *md = ril_modem_data_from_ofono(modem);
DBG("%s", ofono_modem_get_path(modem));
ofono_devinfo_create(modem, 0, RILMODEM_DRIVER, md);
ofono_sim_create(modem, 0, RILMODEM_DRIVER, md);
if (md->modem.config.enable_voicecall) {
ofono_voicecall_create(modem, 0, RILMODEM_DRIVER, md);
}
if (!md->radio_state_event_id) {
md->radio_state_event_id =
ril_radio_add_state_changed_handler(md->modem.radio,
ril_modem_radio_state_cb, md);
}
}
static void ril_modem_post_sim(struct ofono_modem *modem)
{
struct ril_modem_data *md = ril_modem_data_from_ofono(modem);
struct ofono_gprs *gprs;
DBG("%s", ofono_modem_get_path(modem));
ofono_sms_create(modem, 0, RILMODEM_DRIVER, md);
gprs = ofono_gprs_create(modem, 0, RILMODEM_DRIVER, md);
if (gprs) {
int i;
for (i = 0; i < MAX_PDP_CONTEXTS; i++) {
struct ofono_gprs_context *gc =
ofono_gprs_context_create(modem, 0,
RILMODEM_DRIVER, md);
if (gc == NULL)
break;
ofono_gprs_add_context(gprs, gc);
}
}
ofono_phonebook_create(modem, 0, RILMODEM_DRIVER, md);
ofono_call_forwarding_create(modem, 0, RILMODEM_DRIVER, md);
ofono_call_barring_create(modem, 0, RILMODEM_DRIVER, md);
ofono_stk_create(modem, 0, RILMODEM_DRIVER, md);
ofono_cbs_create(modem, 0, RILMODEM_DRIVER, md);
ofono_message_waiting_register(ofono_message_waiting_create(modem));
}
static void ril_modem_post_online(struct ofono_modem *modem)
{
struct ril_modem_data *md = ril_modem_data_from_ofono(modem);
DBG("%s", ofono_modem_get_path(modem));
ofono_call_volume_create(modem, 0, RILMODEM_DRIVER, md);
ofono_netreg_create(modem, 0, RILMODEM_DRIVER, md);
ofono_ussd_create(modem, 0, RILMODEM_DRIVER, md);
ofono_call_settings_create(modem, 0, RILMODEM_DRIVER, md);
ofono_netmon_create(modem, 0, RILMODEM_DRIVER, md);
}
static void ril_modem_set_online(struct ofono_modem *modem, ofono_bool_t online,
ofono_modem_online_cb_t cb, void *data)
{
struct ril_modem_data *md = ril_modem_data_from_ofono(modem);
struct ril_radio *radio = md->modem.radio;
struct ril_modem_online_request *req;
DBG("%s going %sline", ofono_modem_get_path(modem),
online ? "on" : "off");
ril_radio_set_online(radio, online);
if (online) {
ril_radio_power_on(radio, RADIO_POWER_TAG(md));
req = &md->set_online;
} else {
ril_radio_power_off(radio, RADIO_POWER_TAG(md));
req = &md->set_offline;
}
req->cb = cb;
req->data = data;
if (req->timeout_id) {
g_source_remove(req->timeout_id);
}
req->timeout_id = g_timeout_add_seconds(ONLINE_TIMEOUT_SECS,
ril_modem_online_request_timeout, req);
ril_modem_schedule_online_check(md);
}
static int ril_modem_enable(struct ofono_modem *modem)
{
struct ril_modem_data *md = ril_modem_data_from_ofono(modem);
DBG("%s", ofono_modem_get_path(modem));
md->power_state = POWERED_ON;
return 0;
}
static int ril_modem_disable(struct ofono_modem *modem)
{
struct ril_modem_data *md = ril_modem_data_from_ofono(modem);
DBG("%s", ofono_modem_get_path(modem));
if (md->set_online.timeout_id || md->set_offline.timeout_id) {
md->power_state = POWERING_OFF;
return -EINPROGRESS;
} else {
md->power_state = POWERED_OFF;
return 0;
}
}
static int ril_modem_probe(struct ofono_modem *modem)
{
DBG("%s", ofono_modem_get_path(modem));
return 0;
}
static void ril_modem_remove(struct ofono_modem *ofono)
{
struct ril_modem_data *md = ril_modem_data_from_ofono(ofono);
struct ril_modem *modem = &md->modem;
DBG("%s", ril_modem_get_path(modem));
ofono_modem_set_data(ofono, NULL);
ril_radio_remove_handler(modem->radio, md->radio_state_event_id);
ril_radio_power_off(modem->radio, RADIO_POWER_TAG(md));
ril_radio_unref(modem->radio);
ril_sim_settings_unref(modem->sim_settings);
sailfish_watch_remove_handler(md->watch, md->imsi_event_id);
sailfish_watch_unref(md->watch);
if (md->online_check_id) {
g_source_remove(md->online_check_id);
}
if (md->set_online.timeout_id) {
g_source_remove(md->set_online.timeout_id);
}
if (md->set_offline.timeout_id) {
g_source_remove(md->set_offline.timeout_id);
}
ril_network_unref(modem->network);
ril_sim_card_unref(modem->sim_card);
ril_data_unref(modem->data);
sailfish_cell_info_unref(modem->cell_info);
grilio_channel_unref(modem->io);
grilio_queue_cancel_all(md->q, FALSE);
grilio_queue_unref(md->q);
g_free(md->ecclist_file);
g_free(md->log_prefix);
g_free(md->imeisv);
g_free(md->imei);
g_free(md);
}
struct ril_modem *ril_modem_create(GRilIoChannel *io, const char *log_prefix,
const char *path, const char *imei, const char *imeisv,
const char *ecclist_file, const struct ril_slot_config *config,
struct ril_radio *radio, struct ril_network *network,
struct ril_sim_card *card, struct ril_data *data,
struct ril_sim_settings *settings,
struct sailfish_cell_info *cell_info)
{
/* Skip the slash from the path, it looks like "/ril_0" */
struct ofono_modem *ofono = ofono_modem_create(path + 1,
RILMODEM_DRIVER);
if (ofono) {
int err;
struct ril_modem_data *md = g_new0(struct ril_modem_data, 1);
struct ril_modem *modem = &md->modem;
/*
* ril_plugin.c must wait until IMEI becomes known before
* creating the modem
*/
GASSERT(imei);
/* Copy config */
modem->config = *config;
modem->imei = md->imei = g_strdup(imei);
modem->imeisv = md->imeisv = g_strdup(imeisv);
modem->log_prefix = log_prefix; /* No need to strdup */
modem->ecclist_file = ecclist_file; /* No need to strdup */
md->log_prefix = (log_prefix && log_prefix[0]) ?
g_strconcat(log_prefix, " ", NULL) : g_strdup("");
modem->ofono = ofono;
modem->radio = ril_radio_ref(radio);
modem->network = ril_network_ref(network);
modem->sim_card = ril_sim_card_ref(card);
modem->sim_settings = ril_sim_settings_ref(settings);
modem->cell_info = sailfish_cell_info_ref(cell_info);
modem->data = ril_data_ref(data);
modem->io = grilio_channel_ref(io);
md->q = grilio_queue_new(io);
md->watch = sailfish_watch_new(path);
md->imsi_event_id =
sailfish_watch_add_imsi_changed_handler(md->watch,
ril_modem_imsi_cb, md);
md->set_online.md = md;
md->set_offline.md = md;
ofono_modem_set_data(ofono, md);
err = ofono_modem_register(ofono);
if (!err) {
ril_radio_power_cycle(modem->radio);
GASSERT(io->connected);
/*
* ofono_modem_reset sets Powered to TRUE without
* issuing PropertyChange signal.
*/
ofono_modem_set_powered(modem->ofono, FALSE);
ofono_modem_set_powered(modem->ofono, TRUE);
md->power_state = POWERED_ON;
/*
* With some RIL implementations, querying available
* band modes causes some magic Android properties to
* appear. Otherwise this request is pretty harmless
* and useless.
*/
grilio_queue_send_request(md->q, NULL,
RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE);
ril_modem_update_radio_settings(md);
return modem;
} else {
ofono_error("Error %d registering %s",
err, RILMODEM_DRIVER);
/*
* If ofono_modem_register() failed, then
* ofono_modem_remove() won't invoke
* ril_modem_remove() callback.
*/
ril_modem_remove(ofono);
}
ofono_modem_remove(ofono);
}
return NULL;
}
const struct ofono_modem_driver ril_modem_driver = {
.name = RILMODEM_DRIVER,
.probe = ril_modem_probe,
.remove = ril_modem_remove,
.enable = ril_modem_enable,
.disable = ril_modem_disable,
.pre_sim = ril_modem_pre_sim,
.post_sim = ril_modem_post_sim,
.post_online = ril_modem_post_online,
.set_online = ril_modem_set_online
};
/*
* Local Variables:
* mode: C
* c-basic-offset: 8
* indent-tabs-mode: t
* End:
*/

View File

@@ -0,0 +1,203 @@
/*
* oFono - Open Source Telephony - RIL-based devices
*
* Copyright (C) 2016-2017 Jolla Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "ril_plugin.h"
#include "ril_util.h"
#include "ril_log.h"
#include <sailfish_cell_info.h>
#include "ofono.h"
struct ril_netmon {
struct ofono_netmon *netmon;
struct sailfish_cell_info *cell_info;
guint register_id;
};
static inline struct ril_netmon *ril_netmon_get_data(struct ofono_netmon *ofono)
{
return ofono ? ofono_netmon_get_data(ofono) : NULL;
}
static void ril_netmon_format_mccmnc(char *s_mcc, char *s_mnc, int mcc, int mnc)
{
s_mcc[0] = 0;
s_mnc[0] = 0;
if (mcc >= 0 && mcc <= 999) {
snprintf(s_mcc, OFONO_MAX_MCC_LENGTH + 1, "%03d", mcc);
if (mnc >= 0 && mnc <= 999) {
const unsigned int mnclen = mnclength(mcc, mnc);
const char *format[] = { "%d", "%02d", "%03d" };
const char *fmt = (mnclen > 0 &&
mnclen <= G_N_ELEMENTS(format)) ?
format[mnclen - 1] : format[0];
snprintf(s_mnc, OFONO_MAX_MNC_LENGTH + 1, fmt, mnc);
}
}
}
static void ril_netmon_notify_gsm(struct ofono_netmon *netmon,
const struct sailfish_cell_info_gsm *gsm)
{
char mcc[OFONO_MAX_MCC_LENGTH + 1];
char mnc[OFONO_MAX_MNC_LENGTH + 1];
ril_netmon_format_mccmnc(mcc, mnc, gsm->mcc, gsm->mnc);
ofono_netmon_serving_cell_notify(netmon,
OFONO_NETMON_CELL_TYPE_GSM,
OFONO_NETMON_INFO_MCC, mcc,
OFONO_NETMON_INFO_MNC, mnc,
OFONO_NETMON_INFO_LAC, gsm->lac,
OFONO_NETMON_INFO_CI, gsm->cid,
OFONO_NETMON_INFO_RSSI, gsm->signalStrength,
OFONO_NETMON_INFO_BER, gsm->bitErrorRate,
OFONO_NETMON_INFO_INVALID);
}
static void ril_netmon_notify_wcdma(struct ofono_netmon *netmon,
const struct sailfish_cell_info_wcdma *wcdma)
{
char mcc[OFONO_MAX_MCC_LENGTH + 1];
char mnc[OFONO_MAX_MNC_LENGTH + 1];
ril_netmon_format_mccmnc(mcc, mnc, wcdma->mcc, wcdma->mnc);
ofono_netmon_serving_cell_notify(netmon,
OFONO_NETMON_CELL_TYPE_UMTS,
OFONO_NETMON_INFO_MCC, mcc,
OFONO_NETMON_INFO_MNC, mnc,
OFONO_NETMON_INFO_LAC, wcdma->lac,
OFONO_NETMON_INFO_CI, wcdma->cid,
OFONO_NETMON_INFO_PSC, wcdma->psc,
OFONO_NETMON_INFO_RSSI, wcdma->signalStrength,
OFONO_NETMON_INFO_BER, wcdma->bitErrorRate,
OFONO_NETMON_INFO_INVALID);
}
static void ril_netmon_notify_lte(struct ofono_netmon *netmon,
const struct sailfish_cell_info_lte *lte)
{
char mcc[OFONO_MAX_MCC_LENGTH + 1];
char mnc[OFONO_MAX_MNC_LENGTH + 1];
ril_netmon_format_mccmnc(mcc, mnc, lte->mcc, lte->mnc);
ofono_netmon_serving_cell_notify(netmon,
OFONO_NETMON_CELL_TYPE_LTE,
OFONO_NETMON_INFO_MCC, mcc,
OFONO_NETMON_INFO_MNC, mnc,
OFONO_NETMON_INFO_CI, lte->ci,
OFONO_NETMON_INFO_RSSI, lte->signalStrength,
OFONO_NETMON_INFO_TIMING_ADVANCE, lte->timingAdvance,
OFONO_NETMON_INFO_INVALID);
}
static void ril_netmon_request_update(struct ofono_netmon *netmon,
ofono_netmon_cb_t cb, void *data)
{
struct ril_netmon *nm = ril_netmon_get_data(netmon);
struct ofono_error error;
GSList *l;
for (l = nm->cell_info->cells; l; l = l->next) {
const struct sailfish_cell *cell = l->data;
if (cell->registered) {
switch (cell->type) {
case SAILFISH_CELL_TYPE_GSM:
ril_netmon_notify_gsm(netmon,
&cell->info.gsm);
break;
case SAILFISH_CELL_TYPE_WCDMA:
ril_netmon_notify_wcdma(netmon,
&cell->info.wcdma);
break;
case SAILFISH_CELL_TYPE_LTE:
ril_netmon_notify_lte(netmon,
&cell->info.lte);
break;
default:
break;
}
}
}
cb(ril_error_ok(&error), data);
}
static gboolean ril_netmon_register(gpointer user_data)
{
struct ril_netmon *nm = user_data;
GASSERT(nm->register_id);
nm->register_id = 0;
ofono_netmon_register(nm->netmon);
return G_SOURCE_REMOVE;
}
static int ril_netmon_probe(struct ofono_netmon *netmon, unsigned int vendor,
void *data)
{
struct ril_modem *modem = data;
int ret;
if (modem->cell_info) {
struct ril_netmon *nm = g_slice_new0(struct ril_netmon);
nm->cell_info = sailfish_cell_info_ref(modem->cell_info);
nm->netmon = netmon;
ofono_netmon_set_data(netmon, nm);
nm->register_id = g_idle_add(ril_netmon_register, nm);
ret = 0;
} else {
DBG("%s no", modem->log_prefix ? modem->log_prefix : "");
ret = -1;
}
DBG("%s %d", modem->log_prefix ? modem->log_prefix : "", ret);
return ret;
}
static void ril_netmon_remove(struct ofono_netmon *netmon)
{
struct ril_netmon *nm = ril_netmon_get_data(netmon);
DBG("");
ofono_netmon_set_data(netmon, NULL);
if (nm->register_id > 0) {
g_source_remove(nm->register_id);
}
sailfish_cell_info_unref(nm->cell_info);
g_slice_free(struct ril_netmon, nm);
}
const struct ofono_netmon_driver ril_netmon_driver = {
.name = RILMODEM_DRIVER,
.probe = ril_netmon_probe,
.remove = ril_netmon_remove,
.request_update = ril_netmon_request_update,
};
/*
* Local Variables:
* mode: C
* c-basic-offset: 8
* indent-tabs-mode: t
* End:
*/

View File

@@ -0,0 +1,552 @@
/*
* oFono - Open Source Telephony - RIL-based devices
*
* Copyright (C) 2015-2016 Jolla Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "ril_plugin.h"
#include "ril_network.h"
#include "ril_util.h"
#include "ril_log.h"
#include "common.h"
#include "simutil.h"
enum ril_netreg_events {
NETREG_RIL_EVENT_NITZ_TIME_RECEIVED,
NETREG_RIL_EVENT_SIGNAL_STRENGTH,
NETREG_RIL_EVENT_COUNT
};
enum ril_netreg_network_events {
NETREG_NETWORK_EVENT_OPERATOR_CHANGED,
NETREG_NETWORK_EVENT_VOICE_STATE_CHANGED,
NETREG_NETWORK_EVENT_COUNT
};
struct ril_netreg {
GRilIoChannel *io;
GRilIoQueue *q;
struct ofono_netreg *netreg;
struct ril_network *network;
char *log_prefix;
guint timer_id;
guint notify_id;
guint current_operator_id;
gulong ril_event_id[NETREG_RIL_EVENT_COUNT];
gulong network_event_id[NETREG_NETWORK_EVENT_COUNT];
};
struct ril_netreg_cbd {
struct ril_netreg *nd;
union {
ofono_netreg_status_cb_t status;
ofono_netreg_operator_cb_t operator;
ofono_netreg_operator_list_cb_t operator_list;
ofono_netreg_register_cb_t reg;
ofono_netreg_strength_cb_t strength;
gpointer ptr;
} cb;
gpointer data;
};
#define ril_netreg_cbd_free g_free
static inline struct ril_netreg *ril_netreg_get_data(struct ofono_netreg *ofono)
{
return ofono ? ofono_netreg_get_data(ofono) : NULL;
}
static struct ril_netreg_cbd *ril_netreg_cbd_new(struct ril_netreg *nd,
void *cb, void *data)
{
struct ril_netreg_cbd *cbd = g_new0(struct ril_netreg_cbd, 1);
cbd->nd = nd;
cbd->cb.ptr = cb;
cbd->data = data;
return cbd;
}
int ril_netreg_check_if_really_roaming(struct ofono_netreg *netreg,
gint status)
{
if (status == NETWORK_REGISTRATION_STATUS_ROAMING) {
/* These functions tolerate NULL argument */
const char *net_mcc = ofono_netreg_get_mcc(netreg);
const char *net_mnc = ofono_netreg_get_mnc(netreg);
struct sim_spdi *spdi = ofono_netreg_get_spdi(netreg);
if (spdi && net_mcc && net_mnc) {
if (sim_spdi_lookup(spdi, net_mcc, net_mnc)) {
ofono_info("not roaming based on spdi");
return NETWORK_REGISTRATION_STATUS_REGISTERED;
}
}
}
return status;
}
static int ril_netreg_check_status(struct ril_netreg *nd, int status)
{
return (nd && nd->netreg) ?
ril_netreg_check_if_really_roaming(nd->netreg, status) :
status;
}
static gboolean ril_netreg_status_notify_cb(gpointer user_data)
{
struct ril_netreg *nd = user_data;
const struct ril_registration_state *reg = &nd->network->voice;
DBG("%s", nd->log_prefix);
GASSERT(nd->notify_id);
nd->notify_id = 0;
ofono_netreg_status_notify(nd->netreg,
ril_netreg_check_status(nd, reg->status),
reg->lac, reg->ci, reg->access_tech);
return FALSE;
}
static void ril_netreg_status_notify(struct ril_network *net, void *user_data)
{
struct ril_netreg *nd = user_data;
/* Coalesce multiple notifications into one */
if (nd->notify_id) {
DBG("%snotification aready queued", nd->log_prefix);
} else {
DBG("%squeuing notification", nd->log_prefix);
nd->notify_id = g_idle_add(ril_netreg_status_notify_cb, nd);
}
}
static void ril_netreg_registration_status(struct ofono_netreg *netreg,
ofono_netreg_status_cb_t cb, void *data)
{
struct ril_netreg *nd = ril_netreg_get_data(netreg);
const struct ril_registration_state *reg = &nd->network->voice;
struct ofono_error error;
DBG("%s", nd->log_prefix);
cb(ril_error_ok(&error),
ril_netreg_check_status(nd, reg->status),
reg->lac, reg->ci, reg->access_tech, data);
}
static gboolean ril_netreg_current_operator_cb(void *user_data)
{
struct ril_netreg_cbd *cbd = user_data;
struct ril_netreg *nd = cbd->nd;
ofono_netreg_operator_cb_t cb = cbd->cb.operator;
struct ofono_error error;
DBG("%s", nd->log_prefix);
GASSERT(nd->current_operator_id);
nd->current_operator_id = 0;
cb(ril_error_ok(&error), nd->network->operator, cbd->data);
return FALSE;
}
static void ril_netreg_current_operator(struct ofono_netreg *netreg,
ofono_netreg_operator_cb_t cb, void *data)
{
struct ril_netreg *nd = ril_netreg_get_data(netreg);
/*
* Calling ofono_netreg_status_notify() may result in
* ril_netreg_current_operator() being invoked even if one
* is already pending. Since ofono core doesn't associate
* any context with individual calls, we can safely assume
* that such a call essentially cancels the previous one.
*/
if (nd->current_operator_id) {
g_source_remove(nd->current_operator_id);
}
nd->current_operator_id = g_idle_add_full(G_PRIORITY_DEFAULT_IDLE,
ril_netreg_current_operator_cb,
ril_netreg_cbd_new(nd, cb, data),
ril_netreg_cbd_free);
}
static void ril_netreg_list_operators_cb(GRilIoChannel *io, int status,
const void *data, guint len, void *user_data)
{
struct ril_netreg_cbd *cbd = user_data;
ofono_netreg_operator_list_cb_t cb = cbd->cb.operator_list;
struct ofono_network_operator *list;
struct ofono_error error;
int noperators = 0, i;
GRilIoParser rilp;
gboolean ok = TRUE;
if (status != RIL_E_SUCCESS) {
ofono_error("Failed to retrive the list of operators: %s",
ril_error_to_string(status));
cb(ril_error_failure(&error), 0, NULL, cbd->data);
return;
}
grilio_parser_init(&rilp, data, len);
/* Number of operators at the list (4 strings for every operator) */
grilio_parser_get_int32(&rilp, &noperators);
GASSERT(!(noperators % 4));
noperators /= 4;
ofono_info("noperators = %d", noperators);
list = g_new0(struct ofono_network_operator, noperators);
for (i = 0; i < noperators && ok; i++) {
struct ofono_network_operator *op = list + i;
char *lalpha = grilio_parser_get_utf8(&rilp);
char *salpha = grilio_parser_get_utf8(&rilp);
char *numeric = grilio_parser_get_utf8(&rilp);
char *status = grilio_parser_get_utf8(&rilp);
/* Try to use long by default */
if (lalpha) {
strncpy(op->name, lalpha,
OFONO_MAX_OPERATOR_NAME_LENGTH);
} else if (salpha) {
strncpy(op->name, salpha,
OFONO_MAX_OPERATOR_NAME_LENGTH);
} else {
op->name[0] = 0;
}
/* Set the proper status */
if (!strcmp(status, "available")) {
list[i].status = OPERATOR_STATUS_AVAILABLE;
} else if (!strcmp(status, "current")) {
list[i].status = OPERATOR_STATUS_CURRENT;
} else if (!strcmp(status, "forbidden")) {
list[i].status = OPERATOR_STATUS_FORBIDDEN;
} else {
list[i].status = OPERATOR_STATUS_UNKNOWN;
}
op->tech = -1;
ok = ril_parse_mcc_mnc(numeric, op);
if (ok) {
if (op->tech < 0) {
op->tech = cbd->nd->network->voice.access_tech;
}
DBG("[operator=%s, %s, %s, status: %s]", op->name,
op->mcc, op->mnc, status);
} else {
DBG("failed to parse operator list");
}
g_free(lalpha);
g_free(salpha);
g_free(numeric);
g_free(status);
}
if (ok) {
cb(ril_error_ok(&error), noperators, list, cbd->data);
} else {
cb(ril_error_failure(&error), 0, NULL, cbd->data);
}
g_free(list);
}
static void ril_netreg_list_operators(struct ofono_netreg *netreg,
ofono_netreg_operator_list_cb_t cb, void *data)
{
struct ril_netreg *nd = ril_netreg_get_data(netreg);
grilio_queue_send_request_full(nd->q, NULL,
RIL_REQUEST_QUERY_AVAILABLE_NETWORKS,
ril_netreg_list_operators_cb, ril_netreg_cbd_free,
ril_netreg_cbd_new(nd, cb, data));
}
static void ril_netreg_register_cb(GRilIoChannel *io, int status,
const void *data, guint len, void *user_data)
{
struct ril_netreg_cbd *cbd = user_data;
ofono_netreg_register_cb_t cb = cbd->cb.reg;
struct ofono_error error;
if (status == RIL_E_SUCCESS) {
cb(ril_error_ok(&error), cbd->data);
} else {
ofono_error("registration failed, ril result %d", status);
cb(ril_error_failure(&error), cbd->data);
}
}
static void ril_netreg_register_auto(struct ofono_netreg *netreg,
ofono_netreg_register_cb_t cb, void *data)
{
struct ril_netreg *nd = ril_netreg_get_data(netreg);
ofono_info("nw select automatic");
grilio_queue_send_request_full(nd->q, NULL,
RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC,
ril_netreg_register_cb, ril_netreg_cbd_free,
ril_netreg_cbd_new(nd, cb, data));
}
static void ril_netreg_register_manual(struct ofono_netreg *netreg,
const char *mcc, const char *mnc,
ofono_netreg_register_cb_t cb, void *data)
{
struct ril_netreg *nd = ril_netreg_get_data(netreg);
GRilIoRequest *req = grilio_request_new();
ofono_info("nw select manual: %s%s", mcc, mnc);
grilio_request_append_format(req, "%s%s+0", mcc, mnc);
grilio_queue_send_request_full(nd->q, req,
RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL,
ril_netreg_register_cb, ril_netreg_cbd_free,
ril_netreg_cbd_new(nd, cb, data));
grilio_request_unref(req);
}
static int ril_netreg_get_signal_strength(const void *data, guint len)
{
GRilIoParser rilp;
int gw_signal = 0, cdma_dbm = 0, evdo_dbm = 0, lte_signal = 0;
grilio_parser_init(&rilp, data, len);
/* RIL_SignalStrength_v6 */
/* GW_SignalStrength */
grilio_parser_get_int32(&rilp, &gw_signal);
grilio_parser_get_int32(&rilp, NULL); /* bitErrorRate */
/* CDMA_SignalStrength */
grilio_parser_get_int32(&rilp, &cdma_dbm);
grilio_parser_get_int32(&rilp, NULL); /* ecio */
/* EVDO_SignalStrength */
grilio_parser_get_int32(&rilp, &evdo_dbm);
grilio_parser_get_int32(&rilp, NULL); /* ecio */
grilio_parser_get_int32(&rilp, NULL); /* signalNoiseRatio */
/* LTE_SignalStrength */
grilio_parser_get_int32(&rilp, &lte_signal);
grilio_parser_get_int32(&rilp, NULL); /* rsrp */
grilio_parser_get_int32(&rilp, NULL); /* rsrq */
grilio_parser_get_int32(&rilp, NULL); /* rssnr */
grilio_parser_get_int32(&rilp, NULL); /* cqi */
DBG("gw: %d, cdma: %d, evdo: %d, lte: %d", gw_signal, cdma_dbm,
evdo_dbm, lte_signal);
/* Return the first valid one */
if (gw_signal != 99 && gw_signal != -1) {
return (gw_signal * 100) / 31;
}
if (lte_signal != 99 && lte_signal != -1) {
return (lte_signal * 100) / 31;
}
/* In case of dbm, return the value directly */
if (cdma_dbm != -1) {
return MIN(cdma_dbm, 100);
}
if (evdo_dbm != -1) {
return MIN(evdo_dbm, 100);
}
return -1;
}
static void ril_netreg_strength_notify(GRilIoChannel *io, guint ril_event,
const void *data, guint len, void *user_data)
{
struct ril_netreg *nd = user_data;
int strength;
GASSERT(ril_event == RIL_UNSOL_SIGNAL_STRENGTH);
strength = ril_netreg_get_signal_strength(data, len);
DBG("%d", strength);
ofono_netreg_strength_notify(nd->netreg, strength);
}
static void ril_netreg_strength_cb(GRilIoChannel *io, int status,
const void *data, guint len, void *user_data)
{
struct ril_netreg_cbd *cbd = user_data;
ofono_netreg_strength_cb_t cb = cbd->cb.strength;
struct ofono_error error;
if (status == RIL_E_SUCCESS) {
int strength = ril_netreg_get_signal_strength(data, len);
cb(ril_error_ok(&error), strength, cbd->data);
} else {
ofono_error("Failed to retrive the signal strength: %s",
ril_error_to_string(status));
cb(ril_error_failure(&error), -1, cbd->data);
}
}
static void ril_netreg_strength(struct ofono_netreg *netreg,
ofono_netreg_strength_cb_t cb, void *data)
{
struct ril_netreg *nd = ril_netreg_get_data(netreg);
GRilIoRequest* req = grilio_request_new();
grilio_request_set_retry(req, RIL_RETRY_MS, -1);
grilio_queue_send_request_full(nd->q, req,
RIL_REQUEST_SIGNAL_STRENGTH, ril_netreg_strength_cb,
ril_netreg_cbd_free, ril_netreg_cbd_new(nd, cb, data));
grilio_request_unref(req);
}
static void ril_netreg_nitz_notify(GRilIoChannel *io, guint ril_event,
const void *data, guint len, void *user_data)
{
struct ril_netreg *nd = user_data;
GRilIoParser rilp;
struct ofono_network_time time;
int year, mon, mday, hour, min, sec, dst, tzi;
char tzs, tz[4];
gchar *nitz;
GASSERT(ril_event == RIL_UNSOL_NITZ_TIME_RECEIVED);
grilio_parser_init(&rilp, data, len);
nitz = grilio_parser_get_utf8(&rilp);
DBG("%s", nitz);
sscanf(nitz, "%u/%u/%u,%u:%u:%u%c%u,%u", &year, &mon, &mday,
&hour, &min, &sec, &tzs, &tzi, &dst);
snprintf(tz, sizeof(tz), "%c%d", tzs, tzi);
time.utcoff = atoi(tz) * 15 * 60;
time.dst = dst;
time.sec = sec;
time.min = min;
time.hour = hour;
time.mday = mday;
time.mon = mon;
time.year = 2000 + year;
ofono_netreg_time_notify(nd->netreg, &time);
g_free(nitz);
}
static gboolean ril_netreg_register(gpointer user_data)
{
struct ril_netreg *nd = user_data;
GASSERT(nd->timer_id);
nd->timer_id = 0;
ofono_netreg_register(nd->netreg);
/* Register for network state changes */
nd->network_event_id[NETREG_NETWORK_EVENT_OPERATOR_CHANGED] =
ril_network_add_operator_changed_handler(nd->network,
ril_netreg_status_notify, nd);
nd->network_event_id[NETREG_NETWORK_EVENT_VOICE_STATE_CHANGED] =
ril_network_add_voice_state_changed_handler(nd->network,
ril_netreg_status_notify, nd);
/* Register for network time updates */
nd->ril_event_id[NETREG_RIL_EVENT_NITZ_TIME_RECEIVED] =
grilio_channel_add_unsol_event_handler(nd->io,
ril_netreg_nitz_notify,
RIL_UNSOL_NITZ_TIME_RECEIVED, nd);
/* Register for signal strength changes */
nd->ril_event_id[NETREG_RIL_EVENT_SIGNAL_STRENGTH] =
grilio_channel_add_unsol_event_handler(nd->io,
ril_netreg_strength_notify,
RIL_UNSOL_SIGNAL_STRENGTH, nd);
/* This makes the timeout a single-shot */
return FALSE;
}
static int ril_netreg_probe(struct ofono_netreg *netreg, unsigned int vendor,
void *data)
{
struct ril_modem *modem = data;
struct ril_netreg *nd = g_new0(struct ril_netreg, 1);
guint slot = ril_modem_slot(modem);
DBG("[%u] %p", slot, netreg);
nd->log_prefix = g_strdup_printf("%s_%u ", RILMODEM_DRIVER, slot);
nd->io = grilio_channel_ref(ril_modem_io(modem));
nd->q = grilio_queue_new(nd->io);
nd->network = ril_network_ref(modem->network);
nd->netreg = netreg;
ofono_netreg_set_data(netreg, nd);
nd->timer_id = g_idle_add(ril_netreg_register, nd);
return 0;
}
static void ril_netreg_remove(struct ofono_netreg *netreg)
{
struct ril_netreg *nd = ril_netreg_get_data(netreg);
unsigned int i;
DBG("%p", netreg);
grilio_queue_cancel_all(nd->q, FALSE);
ofono_netreg_set_data(netreg, NULL);
if (nd->timer_id > 0) {
g_source_remove(nd->timer_id);
}
if (nd->notify_id) {
g_source_remove(nd->notify_id);
}
if (nd->current_operator_id) {
g_source_remove(nd->current_operator_id);
}
for (i=0; i<G_N_ELEMENTS(nd->network_event_id); i++) {
ril_network_remove_handler(nd->network, nd->network_event_id[i]);
}
ril_network_unref(nd->network);
grilio_channel_remove_handlers(nd->io, nd->ril_event_id,
G_N_ELEMENTS(nd->ril_event_id));
grilio_channel_unref(nd->io);
grilio_queue_unref(nd->q);
g_free(nd->log_prefix);
g_free(nd);
}
const struct ofono_netreg_driver ril_netreg_driver = {
.name = RILMODEM_DRIVER,
.probe = ril_netreg_probe,
.remove = ril_netreg_remove,
.registration_status = ril_netreg_registration_status,
.current_operator = ril_netreg_current_operator,
.list_operators = ril_netreg_list_operators,
.register_auto = ril_netreg_register_auto,
.register_manual = ril_netreg_register_manual,
.strength = ril_netreg_strength
};
/*
* Local Variables:
* mode: C
* c-basic-offset: 8
* indent-tabs-mode: t
* End:
*/

View File

@@ -0,0 +1,940 @@
/*
* oFono - Open Source Telephony - RIL-based devices
*
* Copyright (C) 2015-2017 Jolla Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "ril_network.h"
#include "ril_radio.h"
#include "ril_sim_card.h"
#include "ril_sim_settings.h"
#include "ril_util.h"
#include "ril_log.h"
#include <grilio_queue.h>
#include <grilio_request.h>
#include <grilio_parser.h>
#include <gutil_misc.h>
#include <ofono/netreg.h>
#include "common.h"
#define SET_PREF_MODE_HOLDOFF_SEC RIL_RETRY_SECS
typedef GObjectClass RilNetworkClass;
typedef struct ril_network RilNetwork;
enum ril_network_timer {
TIMER_SET_RAT_HOLDOFF,
TIMER_FORCE_CHECK_PREF_MODE,
TIMER_COUNT
};
enum ril_network_radio_event {
RADIO_EVENT_STATE_CHANGED,
RADIO_EVENT_ONLINE_CHANGED,
RADIO_EVENT_COUNT
};
enum ril_network_unsol_event {
UNSOL_EVENT_NETWORK_STATE,
UNSOL_EVENT_RADIO_CAPABILITY,
UNSOL_EVENT_COUNT
};
struct ril_network_priv {
GRilIoChannel *io;
GRilIoQueue *q;
struct ril_radio *radio;
struct ril_sim_card *sim_card;
int rat;
char *log_prefix;
guint operator_poll_id;
guint voice_poll_id;
guint data_poll_id;
guint timer[TIMER_COUNT];
gulong query_rat_id;
gulong set_rat_id;
gulong unsol_event_id[UNSOL_EVENT_COUNT];
gulong settings_event_id;
gulong sim_status_event_id;
gulong radio_event_id[RADIO_EVENT_COUNT];
struct ofono_network_operator operator;
gboolean assert_rat;
};
enum ril_network_signal {
SIGNAL_OPERATOR_CHANGED,
SIGNAL_VOICE_STATE_CHANGED,
SIGNAL_DATA_STATE_CHANGED,
SIGNAL_PREF_MODE_CHANGED,
SIGNAL_MAX_PREF_MODE_CHANGED,
SIGNAL_COUNT
};
#define SIGNAL_OPERATOR_CHANGED_NAME "ril-network-operator-changed"
#define SIGNAL_VOICE_STATE_CHANGED_NAME "ril-network-voice-state-changed"
#define SIGNAL_DATA_STATE_CHANGED_NAME "ril-network-data-state-changed"
#define SIGNAL_PREF_MODE_CHANGED_NAME "ril-network-pref-mode-changed"
#define SIGNAL_MAX_PREF_MODE_CHANGED_NAME "ril-network-max-pref-mode-changed"
static guint ril_network_signals[SIGNAL_COUNT] = { 0 };
G_DEFINE_TYPE(RilNetwork, ril_network, G_TYPE_OBJECT)
#define RIL_NETWORK_TYPE (ril_network_get_type())
#define RIL_NETWORK(obj) (G_TYPE_CHECK_INSTANCE_CAST(obj,\
RIL_NETWORK_TYPE,RilNetwork))
#define RIL_NETWORK_SIGNAL(klass,name) \
ril_network_signals[SIGNAL_##name##_CHANGED] = \
g_signal_new(SIGNAL_##name##_CHANGED_NAME, \
G_OBJECT_CLASS_TYPE(klass), G_SIGNAL_RUN_FIRST, \
0, NULL, NULL, NULL, G_TYPE_NONE, 0)
#define DBG_(self,fmt,args...) DBG("%s" fmt, (self)->priv->log_prefix, ##args)
/* Some assumptions: */
G_STATIC_ASSERT(OFONO_RADIO_ACCESS_MODE_ANY == 0);
G_STATIC_ASSERT(OFONO_RADIO_ACCESS_MODE_GSM > OFONO_RADIO_ACCESS_MODE_ANY);
G_STATIC_ASSERT(OFONO_RADIO_ACCESS_MODE_UMTS > OFONO_RADIO_ACCESS_MODE_GSM);
G_STATIC_ASSERT(OFONO_RADIO_ACCESS_MODE_LTE > OFONO_RADIO_ACCESS_MODE_UMTS);
static void ril_network_query_pref_mode(struct ril_network *self);
static void ril_network_set_pref_mode(struct ril_network *self, int rat);
static void ril_network_emit(struct ril_network *self,
enum ril_network_signal sig)
{
g_signal_emit(self, ril_network_signals[sig], 0);
}
static void ril_network_stop_timer(struct ril_network *self,
enum ril_network_timer tid)
{
struct ril_network_priv *priv = self->priv;
if (priv->timer[tid]) {
g_source_remove(priv->timer[tid]);
priv->timer[tid] = 0;
}
}
static void ril_network_reset_state(struct ril_registration_state *reg)
{
memset(reg, 0, sizeof(*reg));
reg->status = NETWORK_REGISTRATION_STATUS_UNKNOWN;
reg->access_tech = -1;
reg->ril_tech = -1;
reg->lac = -1;
reg->ci = -1;
}
static gboolean ril_network_parse_response(struct ril_network *self,
const void *data, guint len, struct ril_registration_state *reg)
{
int nparams, ril_status;
gchar *sstatus = NULL, *slac = NULL, *sci = NULL;
gchar *stech = NULL, *sreason = NULL, *smax = NULL;
GRilIoParser rilp;
ril_network_reset_state(reg);
/* Size of response string array. The minimum seen in the wild is 3 */
grilio_parser_init(&rilp, data, len);
if (!grilio_parser_get_int32(&rilp, &nparams) || nparams < 3) {
DBG_(self, "broken response");
return FALSE;
}
sstatus = grilio_parser_get_utf8(&rilp); /* response[0] */
if (!sstatus) {
DBG_(self, "No sstatus value returned!");
return FALSE;
}
slac = grilio_parser_get_utf8(&rilp); /* response[1] */
sci = grilio_parser_get_utf8(&rilp); /* response[2] */
if (nparams > 3) {
stech = grilio_parser_get_utf8(&rilp); /* response[3] */
}
ril_status = atoi(sstatus);
if (ril_status > 10) {
reg->status = ril_status - 10;
} else {
reg->status = ril_status;
}
/* FIXME: need to review VOICE_REGISTRATION response
* as it returns up to 15 parameters ( vs. 6 for DATA ).
*
* The first four parameters are the same for both
* responses ( although status includes values for
* emergency calls for VOICE response ).
*
* Parameters 5 & 6 have different meanings for
* voice & data response.
*/
if (nparams > 4) {
/* TODO: different use for CDMA */
sreason = grilio_parser_get_utf8(&rilp); /* response[4] */
if (nparams > 5) {
/* TODO: different use for CDMA */
smax = grilio_parser_get_utf8(&rilp); /* response[5] */
if (smax) {
reg->max_calls = atoi(smax);
}
}
}
/*
* Some older RILs don't provide max calls, in that case let's
* supply some reasonable default. We don't need more than 2
* simultaneous data calls anyway.
*/
if (reg->max_calls < 1) {
reg->max_calls = 2;
}
if (!ril_parse_int(slac, 16, &reg->lac)) {
reg->lac = -1;
}
if (!ril_parse_int(sci, 16, &reg->ci)) {
reg->ci = -1;
}
reg->access_tech = ril_parse_tech(stech, &reg->ril_tech);
DBG_(self, "%s,%s,%s,%d,%s,%s,%s",
registration_status_to_string(reg->status),
slac, sci, reg->ril_tech,
registration_tech_to_string(reg->access_tech),
sreason, smax);
g_free(sstatus);
g_free(slac);
g_free(sci);
g_free(stech);
g_free(sreason);
g_free(smax);
return TRUE;
}
static void ril_network_op_copy(struct ofono_network_operator *dest,
const struct ofono_network_operator *src)
{
strncpy(dest->mcc, src->mcc, sizeof(dest->mcc));
strncpy(dest->mnc, src->mnc, sizeof(dest->mnc));
strncpy(dest->name, src->name, sizeof(dest->name));
dest->mcc[sizeof(dest->mcc)-1] = 0;
dest->mnc[sizeof(dest->mnc)-1] = 0;
dest->name[sizeof(dest->name)-1] = 0;
dest->status = src->status;
dest->tech = src->tech;
}
static gboolean ril_network_op_equal(const struct ofono_network_operator *op1,
const struct ofono_network_operator *op2)
{
if (op1 == op2) {
return TRUE;
} else if (!op1 || !op2) {
return FALSE;
} else {
return op1->status == op2->status &&
op1->tech == op2->tech &&
!strncmp(op1->mcc, op2->mcc, sizeof(op2->mcc)) &&
!strncmp(op1->mnc, op2->mnc, sizeof(op2->mnc)) &&
!strncmp(op1->name, op2->name, sizeof(op2->name));
}
}
static void ril_network_poll_operator_cb(GRilIoChannel *io, int req_status,
const void *data, guint len, void *user_data)
{
struct ril_network *self = RIL_NETWORK(user_data);
struct ril_network_priv *priv = self->priv;
GASSERT(priv->operator_poll_id);
priv->operator_poll_id = 0;
if (req_status == RIL_E_SUCCESS) {
struct ofono_network_operator op;
gboolean changed = FALSE;
gchar *lalpha;
char *salpha;
char *numeric;
GRilIoParser rilp;
grilio_parser_init(&rilp, data, len);
grilio_parser_get_int32(&rilp, NULL);
lalpha = grilio_parser_get_utf8(&rilp);
salpha = grilio_parser_get_utf8(&rilp);
numeric = grilio_parser_get_utf8(&rilp);
op.tech = -1;
if (ril_parse_mcc_mnc(numeric, &op)) {
if (op.tech < 0) op.tech = self->voice.access_tech;
op.status = OPERATOR_STATUS_CURRENT;
op.name[0] = 0;
if (lalpha) {
strncpy(op.name, lalpha, sizeof(op.name));
} else if (salpha) {
strncpy(op.name, salpha, sizeof(op.name));
} else {
strncpy(op.name, numeric, sizeof(op.name));
}
op.name[sizeof(op.name)-1] = 0;
if (!self->operator) {
self->operator = &priv->operator;
ril_network_op_copy(&priv->operator, &op);
changed = TRUE;
} else if (!ril_network_op_equal(&op, &priv->operator)) {
ril_network_op_copy(&priv->operator, &op);
changed = TRUE;
}
} else if (self->operator) {
self->operator = NULL;
changed = TRUE;
}
if (changed) {
if (self->operator) {
DBG_(self, "lalpha=%s, salpha=%s, numeric=%s, "
"%s, mcc=%s, mnc=%s, %s",
lalpha, salpha, numeric,
op.name, op.mcc, op.mnc,
registration_tech_to_string(op.tech));
} else {
DBG_(self, "no operator");
}
ril_network_emit(self, SIGNAL_OPERATOR_CHANGED);
}
g_free(lalpha);
g_free(salpha);
g_free(numeric);
}
}
static void ril_network_poll_voice_state_cb(GRilIoChannel *io, int req_status,
const void *data, guint len, void *user_data)
{
struct ril_network *self = RIL_NETWORK(user_data);
struct ril_network_priv *priv = self->priv;
GASSERT(priv->voice_poll_id);
priv->voice_poll_id = 0;
if (req_status == RIL_E_SUCCESS) {
struct ril_registration_state state;
ril_network_parse_response(self, data, len, &state);
if (memcmp(&state, &self->voice, sizeof(state))) {
DBG_(self, "voice registration changed");
self->voice = state;
ril_network_emit(self, SIGNAL_VOICE_STATE_CHANGED);
}
}
}
static void ril_network_poll_data_state_cb(GRilIoChannel *io, int req_status,
const void *data, guint len, void *user_data)
{
struct ril_network *self = RIL_NETWORK(user_data);
struct ril_network_priv *priv = self->priv;
GASSERT(priv->data_poll_id);
priv->data_poll_id = 0;
if (req_status == RIL_E_SUCCESS) {
struct ril_registration_state state;
ril_network_parse_response(self, data, len, &state);
if (memcmp(&state, &self->data, sizeof(state))) {
DBG_(self, "data registration changed");
self->data = state;
ril_network_emit(self, SIGNAL_DATA_STATE_CHANGED);
}
}
}
static guint ril_network_poll_and_retry(struct ril_network *self, guint id,
int code, GRilIoChannelResponseFunc fn)
{
struct ril_network_priv *priv = self->priv;
if (id) {
/* Retry right away, don't wait for retry timeout to expire */
grilio_channel_retry_request(priv->io, id);
} else {
GRilIoRequest *req = grilio_request_new();
grilio_request_set_retry(req, RIL_RETRY_SECS*1000, -1);
id = grilio_queue_send_request_full(priv->q, req, code, fn,
NULL, self);
grilio_request_unref(req);
}
return id;
}
static void ril_network_poll_state(struct ril_network *self)
{
struct ril_network_priv *priv = self->priv;
DBG_(self, "");
priv->operator_poll_id = ril_network_poll_and_retry(self,
priv->operator_poll_id, RIL_REQUEST_OPERATOR,
ril_network_poll_operator_cb);
priv->voice_poll_id = ril_network_poll_and_retry(self,
priv->voice_poll_id, RIL_REQUEST_VOICE_REGISTRATION_STATE,
ril_network_poll_voice_state_cb);
priv->data_poll_id = ril_network_poll_and_retry(self,
priv->data_poll_id, RIL_REQUEST_DATA_REGISTRATION_STATE,
ril_network_poll_data_state_cb);
}
static enum ofono_radio_access_mode ril_network_rat_to_mode(int rat)
{
switch (rat) {
case PREF_NET_TYPE_LTE_CDMA_EVDO:
case PREF_NET_TYPE_LTE_GSM_WCDMA:
case PREF_NET_TYPE_LTE_CMDA_EVDO_GSM_WCDMA:
case PREF_NET_TYPE_LTE_ONLY:
case PREF_NET_TYPE_LTE_WCDMA:
return OFONO_RADIO_ACCESS_MODE_LTE;
case PREF_NET_TYPE_GSM_WCDMA_AUTO:
case PREF_NET_TYPE_WCDMA:
case PREF_NET_TYPE_GSM_WCDMA:
return OFONO_RADIO_ACCESS_MODE_UMTS;
default:
DBG("unexpected rat mode %d", rat);
case PREF_NET_TYPE_GSM_ONLY:
return OFONO_RADIO_ACCESS_MODE_GSM;
}
}
static int ril_network_mode_to_rat(struct ril_network *self,
enum ofono_radio_access_mode mode)
{
switch (mode) {
case OFONO_RADIO_ACCESS_MODE_ANY:
case OFONO_RADIO_ACCESS_MODE_LTE:
if (self->settings->techs & OFONO_RADIO_ACCESS_MODE_LTE) {
return PREF_NET_TYPE_LTE_GSM_WCDMA;
}
/* no break */
default:
case OFONO_RADIO_ACCESS_MODE_UMTS:
if (self->settings->techs & OFONO_RADIO_ACCESS_MODE_UMTS) {
return PREF_NET_TYPE_GSM_WCDMA_AUTO;
}
/* no break */
case OFONO_RADIO_ACCESS_MODE_GSM:
return PREF_NET_TYPE_GSM_ONLY;
}
}
static int ril_network_pref_mode_expected(struct ril_network *self)
{
struct ril_sim_settings *settings = self->settings;
struct ril_network_priv *priv = self->priv;
/*
* On dual-SIM phones such as Jolla C only one slot at a time
* is allowed to use LTE. Even if the slot which has been using
* LTE gets powered off, we still need to explicitely set its
* preferred mode to GSM, to make LTE machinery available to
* the other slot. This sort of behaviour might not be necessary
* on some hardware and can (should) be made configurable when
* it becomes necessary.
*/
const enum ofono_radio_access_mode max_pref_mode =
(priv->radio->state == RADIO_STATE_ON) ? self->max_pref_mode :
OFONO_RADIO_ACCESS_MODE_GSM;
/*
* OFONO_RADIO_ACCESS_MODE_ANY is zero. If both pref_mode
* and max_pref_mode are not ANY, we pick the smallest value.
* Otherwise we take any non-zero value if there is one.
*/
const enum ofono_radio_access_mode pref_mode =
(settings->pref_mode && max_pref_mode) ?
MIN(settings->pref_mode, max_pref_mode) :
settings->pref_mode ? settings->pref_mode :
max_pref_mode;
return ril_network_mode_to_rat(self, pref_mode);
}
static gboolean ril_network_can_set_pref_mode(struct ril_network *self)
{
struct ril_network_priv *priv = self->priv;
return priv->radio->online && ril_sim_card_ready(priv->sim_card);
}
static gboolean ril_network_set_rat_holdoff_cb(gpointer user_data)
{
struct ril_network *self = RIL_NETWORK(user_data);
struct ril_network_priv *priv = self->priv;
const int rat = ril_network_pref_mode_expected(self);
DBG_(self, "rat mode %d, expected %d", priv->rat, rat);
GASSERT(priv->timer[TIMER_SET_RAT_HOLDOFF]);
priv->timer[TIMER_SET_RAT_HOLDOFF] = 0;
/*
* Don't retry the request if modem is offline or SIM card isn't
* ready, to avoid spamming system log with error messages. Radio
* and SIM card state change callbacks will schedule a new check
* when it's appropriate.
*/
if (priv->rat != rat || priv->assert_rat) {
if (ril_network_can_set_pref_mode(self)) {
ril_network_set_pref_mode(self, rat);
} else {
DBG_(self, "giving up");
}
}
return G_SOURCE_REMOVE;
}
static void ril_network_set_pref_mode_cb(GRilIoChannel *io, int status,
const void *data, guint len, void *user_data)
{
struct ril_network *self = RIL_NETWORK(user_data);
struct ril_network_priv *priv = self->priv;
GASSERT(priv->set_rat_id);
priv->set_rat_id = 0;
if (status != RIL_E_SUCCESS) {
ofono_error("failed to set rat mode");
}
ril_network_query_pref_mode(self);
}
static void ril_network_set_pref_mode(struct ril_network *self, int rat)
{
struct ril_network_priv *priv = self->priv;
GRilIoRequest *req = grilio_request_sized_new(8);
DBG_(self, "setting rat mode %d", rat);
grilio_request_append_int32(req, 1); /* Number of params */
grilio_request_append_int32(req, rat);
grilio_queue_cancel_request(priv->q, priv->set_rat_id, FALSE);
priv->set_rat_id = grilio_queue_send_request_full(priv->q, req,
RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE,
ril_network_set_pref_mode_cb, NULL, self);
grilio_request_unref(req);
/* We have submitted the request, clear the assertion flag */
priv->assert_rat = FALSE;
/* Don't do it too often */
GASSERT(!priv->timer[TIMER_SET_RAT_HOLDOFF]);
priv->timer[TIMER_SET_RAT_HOLDOFF] =
g_timeout_add_seconds(SET_PREF_MODE_HOLDOFF_SEC,
ril_network_set_rat_holdoff_cb, self);
}
static void ril_network_check_pref_mode(struct ril_network *self,
gboolean force)
{
struct ril_network_priv *priv = self->priv;
const int rat = ril_network_pref_mode_expected(self);
if (priv->timer[TIMER_FORCE_CHECK_PREF_MODE]) {
ril_network_stop_timer(self, TIMER_FORCE_CHECK_PREF_MODE);
/*
* TIMER_FORCE_CHECK_PREF_MODE is scheduled by
* ril_network_pref_mode_changed_cb and is meant
* to force radio tech check right now.
*/
force = TRUE;
}
if (priv->rat == rat || force) {
ril_network_stop_timer(self, TIMER_SET_RAT_HOLDOFF);
}
if (priv->rat != rat || priv->assert_rat) {
if (!priv->timer[TIMER_SET_RAT_HOLDOFF]) {
ril_network_set_pref_mode(self, rat);
} else {
/* OK, later */
DBG_(self, "need to set rat mode %d", rat);
}
}
}
static int ril_network_parse_pref_resp(const void *data, guint len)
{
GRilIoParser rilp;
int pref = -1;
grilio_parser_init(&rilp, data, len);
grilio_parser_get_int32(&rilp, NULL);
grilio_parser_get_int32(&rilp, &pref);
return pref;
}
static void ril_network_startup_query_pref_mode_cb(GRilIoChannel *io,
int status, const void *data, guint len, void *user_data)
{
if (status == RIL_E_SUCCESS) {
struct ril_network *self = RIL_NETWORK(user_data);
struct ril_network_priv *priv = self->priv;
const enum ofono_radio_access_mode pref_mode = self->pref_mode;
priv->rat = ril_network_parse_pref_resp(data, len);
self->pref_mode = ril_network_rat_to_mode(priv->rat);
DBG_(self, "rat mode %d (%s)", priv->rat,
ofono_radio_access_mode_to_string(self->pref_mode));
if (self->pref_mode != pref_mode) {
ril_network_emit(self, SIGNAL_PREF_MODE_CHANGED);
}
/*
* Unlike ril_network_query_pref_mode_cb, this one always
* checks the preferred mode.
*/
ril_network_check_pref_mode(self, FALSE);
}
}
static void ril_network_query_pref_mode_cb(GRilIoChannel *io, int status,
const void *data, guint len, void *user_data)
{
struct ril_network *self = RIL_NETWORK(user_data);
struct ril_network_priv *priv = self->priv;
const enum ofono_radio_access_mode pref_mode = self->pref_mode;
/* This request never fails because in case of error it gets retried */
GASSERT(status == RIL_E_SUCCESS);
GASSERT(priv->query_rat_id);
priv->query_rat_id = 0;
priv->rat = ril_network_parse_pref_resp(data, len);
self->pref_mode = ril_network_rat_to_mode(priv->rat);
DBG_(self, "rat mode %d (%s)", priv->rat,
ofono_radio_access_mode_to_string(self->pref_mode));
if (self->pref_mode != pref_mode) {
ril_network_emit(self, SIGNAL_PREF_MODE_CHANGED);
}
if (ril_network_can_set_pref_mode(self)) {
ril_network_check_pref_mode(self, FALSE);
}
}
static void ril_network_query_pref_mode(struct ril_network *self)
{
struct ril_network_priv *priv = self->priv;
GRilIoRequest *req = grilio_request_new();
grilio_request_set_retry(req, RIL_RETRY_SECS*1000, -1);
grilio_queue_cancel_request(priv->q, priv->query_rat_id, FALSE);
priv->query_rat_id = grilio_queue_send_request_full(priv->q, req,
RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE,
ril_network_query_pref_mode_cb, NULL, self);
grilio_request_unref(req);
}
void ril_network_set_max_pref_mode(struct ril_network *self,
enum ofono_radio_access_mode max_mode,
gboolean force_check)
{
if (self && (self->max_pref_mode != max_mode || force_check)) {
if (self->max_pref_mode != max_mode) {
DBG_(self, "rat mode %d (%s)", max_mode,
ofono_radio_access_mode_to_string(max_mode));
self->max_pref_mode = max_mode;
ril_network_emit(self, SIGNAL_MAX_PREF_MODE_CHANGED);
}
ril_network_check_pref_mode(self, TRUE);
}
}
void ril_network_assert_pref_mode(struct ril_network *self, gboolean immediate)
{
struct ril_network_priv *priv = self->priv;
priv->assert_rat = TRUE;
ril_network_check_pref_mode(self, immediate);
}
gulong ril_network_add_operator_changed_handler(struct ril_network *self,
ril_network_cb_t cb, void *arg)
{
return (G_LIKELY(self) && G_LIKELY(cb)) ? g_signal_connect(self,
SIGNAL_OPERATOR_CHANGED_NAME, G_CALLBACK(cb), arg) : 0;
}
gulong ril_network_add_voice_state_changed_handler(struct ril_network *self,
ril_network_cb_t cb, void *arg)
{
return (G_LIKELY(self) && G_LIKELY(cb)) ? g_signal_connect(self,
SIGNAL_VOICE_STATE_CHANGED_NAME, G_CALLBACK(cb), arg) : 0;
}
gulong ril_network_add_data_state_changed_handler(struct ril_network *self,
ril_network_cb_t cb, void *arg)
{
return (G_LIKELY(self) && G_LIKELY(cb)) ? g_signal_connect(self,
SIGNAL_DATA_STATE_CHANGED_NAME, G_CALLBACK(cb), arg) : 0;
}
gulong ril_network_add_pref_mode_changed_handler(struct ril_network *self,
ril_network_cb_t cb, void *arg)
{
return (G_LIKELY(self) && G_LIKELY(cb)) ? g_signal_connect(self,
SIGNAL_PREF_MODE_CHANGED_NAME, G_CALLBACK(cb), arg) : 0;
}
gulong ril_network_add_max_pref_mode_changed_handler(struct ril_network *self,
ril_network_cb_t cb, void *arg)
{
return (G_LIKELY(self) && G_LIKELY(cb)) ? g_signal_connect(self,
SIGNAL_MAX_PREF_MODE_CHANGED_NAME, G_CALLBACK(cb), arg) : 0;
}
void ril_network_remove_handler(struct ril_network *self, gulong id)
{
if (G_LIKELY(self) && G_LIKELY(id)) {
g_signal_handler_disconnect(self, id);
}
}
void ril_network_remove_handlers(struct ril_network *self, gulong *ids, int n)
{
gutil_disconnect_handlers(self, ids, n);
}
static void ril_network_state_changed_cb(GRilIoChannel *io, guint code,
const void *data, guint len, void *user_data)
{
struct ril_network *self = RIL_NETWORK(user_data);
DBG_(self, "");
GASSERT(code == RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED);
ril_network_poll_state(self);
}
static void ril_network_radio_capability_changed_cb(GRilIoChannel *io,
guint code, const void *data, guint len, void *user_data)
{
struct ril_network *self = RIL_NETWORK(user_data);
DBG_(self, "");
GASSERT(code == RIL_UNSOL_RADIO_CAPABILITY);
ril_network_assert_pref_mode(self, FALSE);
}
static void ril_network_radio_state_cb(struct ril_radio *radio, void *data)
{
struct ril_network *self = RIL_NETWORK(data);
ril_network_check_pref_mode(self, FALSE);
if (radio->state == RADIO_STATE_ON) {
ril_network_poll_state(self);
}
}
static void ril_network_radio_online_cb(struct ril_radio *radio, void *data)
{
struct ril_network *self = RIL_NETWORK(data);
if (ril_network_can_set_pref_mode(self)) {
ril_network_check_pref_mode(self, TRUE);
}
}
static gboolean ril_network_check_pref_mode_cb(gpointer user_data)
{
struct ril_network *self = RIL_NETWORK(user_data);
struct ril_network_priv *priv = self->priv;
GASSERT(priv->timer[TIMER_FORCE_CHECK_PREF_MODE]);
priv->timer[TIMER_FORCE_CHECK_PREF_MODE] = 0;
DBG_(self, "checking pref mode");
ril_network_check_pref_mode(self, TRUE);
return G_SOURCE_REMOVE;
}
static void ril_network_pref_mode_changed_cb(struct ril_sim_settings *settings,
void *user_data)
{
struct ril_network *self = RIL_NETWORK(user_data);
struct ril_network_priv *priv = self->priv;
/*
* Postpone ril_network_check_pref_mode because other pref_mode
* listeners (namely, ril_data) may want to tweak max_pref_mode
*/
if (!priv->timer[TIMER_FORCE_CHECK_PREF_MODE]) {
DBG_(self, "scheduling pref mode check");
priv->timer[TIMER_FORCE_CHECK_PREF_MODE] =
g_idle_add(ril_network_check_pref_mode_cb, self);
} else {
DBG_(self, "pref mode check already scheduled");
}
}
static void ril_network_sim_status_changed_cb(struct ril_sim_card *sc,
void *user_data)
{
struct ril_network *self = RIL_NETWORK(user_data);
if (ril_network_can_set_pref_mode(self)) {
ril_network_check_pref_mode(self, FALSE);
}
}
struct ril_network *ril_network_new(const char *path, GRilIoChannel *io,
const char *log_prefix, struct ril_radio *radio,
struct ril_sim_card *sim_card,
struct ril_sim_settings *settings)
{
struct ril_network *self = g_object_new(RIL_NETWORK_TYPE, NULL);
struct ril_network_priv *priv = self->priv;
self->settings = ril_sim_settings_ref(settings);
priv->io = grilio_channel_ref(io);
priv->q = grilio_queue_new(priv->io);
priv->radio = ril_radio_ref(radio);
priv->sim_card = ril_sim_card_ref(sim_card);
priv->log_prefix = (log_prefix && log_prefix[0]) ?
g_strconcat(log_prefix, " ", NULL) : g_strdup("");
DBG_(self, "");
priv->unsol_event_id[UNSOL_EVENT_NETWORK_STATE] =
grilio_channel_add_unsol_event_handler(priv->io,
ril_network_state_changed_cb,
RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED, self);
priv->unsol_event_id[UNSOL_EVENT_RADIO_CAPABILITY] =
grilio_channel_add_unsol_event_handler(priv->io,
ril_network_radio_capability_changed_cb,
RIL_UNSOL_RADIO_CAPABILITY, self);
priv->radio_event_id[RADIO_EVENT_STATE_CHANGED] =
ril_radio_add_state_changed_handler(priv->radio,
ril_network_radio_state_cb, self);
priv->radio_event_id[RADIO_EVENT_ONLINE_CHANGED] =
ril_radio_add_online_changed_handler(priv->radio,
ril_network_radio_online_cb, self);
priv->settings_event_id =
ril_sim_settings_add_pref_mode_changed_handler(settings,
ril_network_pref_mode_changed_cb, self);
priv->sim_status_event_id =
ril_sim_card_add_status_changed_handler(priv->sim_card,
ril_network_sim_status_changed_cb, self);
/*
* Query the initial state. Querying network state before the radio
* has been turned on makes RIL unhappy.
*/
grilio_queue_send_request_full(priv->q, NULL,
RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE,
ril_network_startup_query_pref_mode_cb, NULL, self);
if (radio->state == RADIO_STATE_ON) {
ril_network_poll_state(self);
}
return self;
}
struct ril_network *ril_network_ref(struct ril_network *self)
{
if (G_LIKELY(self)) {
g_object_ref(RIL_NETWORK(self));
return self;
} else {
return NULL;
}
}
void ril_network_unref(struct ril_network *self)
{
if (G_LIKELY(self)) {
g_object_unref(RIL_NETWORK(self));
}
}
static void ril_network_init(struct ril_network *self)
{
struct ril_network_priv *priv = G_TYPE_INSTANCE_GET_PRIVATE(self,
RIL_NETWORK_TYPE, struct ril_network_priv);
self->priv = priv;
ril_network_reset_state(&self->voice);
ril_network_reset_state(&self->data);
priv->rat = -1;
}
static void ril_network_finalize(GObject *object)
{
struct ril_network *self = RIL_NETWORK(object);
struct ril_network_priv *priv = self->priv;
enum ril_network_timer tid;
DBG_(self, "");
for (tid=0; tid<TIMER_COUNT; tid++) {
ril_network_stop_timer(self, tid);
}
grilio_queue_cancel_all(priv->q, FALSE);
grilio_channel_remove_handlers(priv->io, priv->unsol_event_id,
G_N_ELEMENTS(priv->unsol_event_id));
grilio_channel_unref(priv->io);
grilio_queue_unref(priv->q);
ril_radio_remove_all_handlers(priv->radio, priv->radio_event_id);
ril_radio_unref(priv->radio);
ril_sim_card_remove_handler(priv->sim_card,
priv->sim_status_event_id);
ril_sim_card_unref(priv->sim_card);
ril_sim_settings_remove_handler(self->settings,
priv->settings_event_id);
ril_sim_settings_unref(self->settings);
g_free(priv->log_prefix);
G_OBJECT_CLASS(ril_network_parent_class)->finalize(object);
}
static void ril_network_class_init(RilNetworkClass *klass)
{
G_OBJECT_CLASS(klass)->finalize = ril_network_finalize;
g_type_class_add_private(klass, sizeof(struct ril_network_priv));
RIL_NETWORK_SIGNAL(klass, OPERATOR);
RIL_NETWORK_SIGNAL(klass, VOICE_STATE);
RIL_NETWORK_SIGNAL(klass, DATA_STATE);
RIL_NETWORK_SIGNAL(klass, PREF_MODE);
RIL_NETWORK_SIGNAL(klass, MAX_PREF_MODE);
}
/*
* Local Variables:
* mode: C
* c-basic-offset: 8
* indent-tabs-mode: t
* End:
*/

View File

@@ -0,0 +1,78 @@
/*
* oFono - Open Source Telephony - RIL-based devices
*
* Copyright (C) 2015-2017 Jolla Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#ifndef RIL_NETWORK_H
#define RIL_NETWORK_H
#include "ril_types.h"
struct ofono_network_operator;
struct ril_registration_state {
int status; /* enum network_registration_status */
int access_tech; /* enum access_technology or -1 if none */
int ril_tech;
int max_calls;
int lac;
int ci;
};
struct ril_network {
GObject object;
struct ril_network_priv *priv;
struct ril_registration_state voice;
struct ril_registration_state data;
const struct ofono_network_operator *operator;
enum ofono_radio_access_mode pref_mode;
enum ofono_radio_access_mode max_pref_mode;
struct ril_sim_settings *settings;
};
struct ofono_sim;
typedef void (*ril_network_cb_t)(struct ril_network *net, void *arg);
struct ril_network *ril_network_new(const char *path, GRilIoChannel *io,
const char *log_prefix, struct ril_radio *radio,
struct ril_sim_card *sim_card,
struct ril_sim_settings *settings);
struct ril_network *ril_network_ref(struct ril_network *net);
void ril_network_unref(struct ril_network *net);
void ril_network_set_max_pref_mode(struct ril_network *net,
enum ofono_radio_access_mode max_pref_mode,
gboolean force_check);
void ril_network_assert_pref_mode(struct ril_network *net, gboolean immediate);
gulong ril_network_add_operator_changed_handler(struct ril_network *net,
ril_network_cb_t cb, void *arg);
gulong ril_network_add_voice_state_changed_handler(struct ril_network *net,
ril_network_cb_t cb, void *arg);
gulong ril_network_add_data_state_changed_handler(struct ril_network *net,
ril_network_cb_t cb, void *arg);
gulong ril_network_add_pref_mode_changed_handler(struct ril_network *net,
ril_network_cb_t cb, void *arg);
gulong ril_network_add_max_pref_mode_changed_handler(struct ril_network *net,
ril_network_cb_t cb, void *arg);
void ril_network_remove_handler(struct ril_network *net, gulong id);
void ril_network_remove_handlers(struct ril_network *net, gulong *ids, int n);
#endif /* RIL_NETWORK_H */
/*
* Local Variables:
* mode: C
* c-basic-offset: 8
* indent-tabs-mode: t
* End:
*/

View File

@@ -0,0 +1,162 @@
/*
* oFono - Open Source Telephony - RIL-based devices
*
* Copyright (C) 2015-2017 Jolla Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "ril_plugin.h"
#include "ril_util.h"
#include "ril_log.h"
#include "gdbus.h"
#include "ofono.h"
#define RIL_OEM_RAW_INTERFACE "org.ofono.OemRaw"
#define RIL_OEM_RAW_TIMEOUT (60*1000) /* 60 sec */
struct ril_oem_raw {
GRilIoQueue *q;
DBusConnection *conn;
char *path;
char *log_prefix;
};
#define DBG_(oem,fmt,args...) DBG("%s" fmt, (oem)->log_prefix, ##args)
static void ril_oem_raw_send_cb(GRilIoChannel *io, int ril_status,
const void *data, guint len, void *user_data)
{
DBusMessage *msg = user_data;
DBusMessage *reply;
if (ril_status == RIL_E_SUCCESS) {
DBusMessageIter it, array;
const guchar* bytes = data;
guint i;
reply = dbus_message_new_method_return(msg);
dbus_message_iter_init_append(reply, &it);
dbus_message_iter_open_container(&it, DBUS_TYPE_ARRAY,
DBUS_TYPE_BYTE_AS_STRING, &array);
for (i = 0; i < len; i++) {
guchar byte = bytes[i];
dbus_message_iter_append_basic(&array, DBUS_TYPE_BYTE,
&byte);
}
dbus_message_iter_close_container(&it, &array);
} else if (ril_status == GRILIO_STATUS_TIMEOUT) {
DBG("Timed out");
reply = __ofono_error_timed_out(msg);
} else {
DBG("Error %s", ril_error_to_string(ril_status));
reply = __ofono_error_failed(msg);
}
__ofono_dbus_pending_reply(&msg, reply);
}
static DBusMessage *ril_oem_raw_send(DBusConnection *conn, DBusMessage *msg,
void *user_data)
{
DBusMessageIter it;
struct ril_oem_raw *oem = user_data;
dbus_message_iter_init(msg, &it);
if (dbus_message_iter_get_arg_type(&it) == DBUS_TYPE_ARRAY &&
dbus_message_iter_get_element_type(&it) == DBUS_TYPE_BYTE) {
char *data;
int data_len;
DBusMessageIter array;
GRilIoRequest *req;
/* Fetch the data */
dbus_message_iter_recurse(&it, &array);
dbus_message_iter_get_fixed_array(&array, &data, &data_len);
DBG_(oem, "%d bytes", data_len);
/*
* And forward it to rild. Set a timeout because rild may
* never respond to invalid requests.
*/
req = grilio_request_sized_new(data_len);
grilio_request_set_timeout(req, RIL_OEM_RAW_TIMEOUT);
grilio_request_append_bytes(req, data, data_len);
grilio_queue_send_request_full(oem->q, req,
RIL_REQUEST_OEM_HOOK_RAW, ril_oem_raw_send_cb,
NULL, dbus_message_ref(msg));
grilio_request_unref(req);
return NULL;
} else {
DBG_(oem, "Unexpected signature");
return __ofono_error_invalid_args(msg);
}
}
static const GDBusMethodTable ril_oem_raw_methods[] = {
{ GDBUS_ASYNC_METHOD("Send",
GDBUS_ARGS({ "request", "ay" }),
GDBUS_ARGS({ "response", "ay" }),
ril_oem_raw_send) },
{ }
};
struct ril_oem_raw *ril_oem_raw_new(struct ril_modem *modem,
const char *log_prefix)
{
struct ril_oem_raw *oem = g_new0(struct ril_oem_raw, 1);
DBG("%s", ril_modem_get_path(modem));
oem->path = g_strdup(ril_modem_get_path(modem));
oem->conn = dbus_connection_ref(ofono_dbus_get_connection());
oem->q = grilio_queue_new(ril_modem_io(modem));
oem->log_prefix = (log_prefix && log_prefix[0]) ?
g_strconcat(log_prefix, " ", NULL) : g_strdup("");
/* Register D-Bus interface */
if (g_dbus_register_interface(oem->conn, oem->path,
RIL_OEM_RAW_INTERFACE, ril_oem_raw_methods,
NULL, NULL, oem, NULL)) {
ofono_modem_add_interface(modem->ofono, RIL_OEM_RAW_INTERFACE);
return oem;
} else {
ofono_error("OemRaw D-Bus register failed");
ril_oem_raw_free(oem);
return NULL;
}
}
void ril_oem_raw_free(struct ril_oem_raw *oem)
{
if (oem) {
DBG("%s", oem->path);
g_dbus_unregister_interface(oem->conn, oem->path,
RIL_OEM_RAW_INTERFACE);
dbus_connection_unref(oem->conn);
grilio_queue_cancel_all(oem->q, TRUE);
grilio_queue_unref(oem->q);
g_free(oem->log_prefix);
g_free(oem->path);
g_free(oem);
}
}
/*
* Local Variables:
* mode: C
* c-basic-offset: 8
* indent-tabs-mode: t
* End:
*/

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,115 @@
/*
* oFono - Open Source Telephony - RIL-based devices
*
* Copyright (C) 2015-2017 Jolla Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#ifndef RIL_PLUGIN_H
#define RIL_PLUGIN_H
#include "ril_types.h"
#include "sailfish_manager.h"
#include <ofono/modem.h>
#include <ofono/call-barring.h>
#include <ofono/call-forwarding.h>
#include <ofono/call-settings.h>
#include <ofono/call-volume.h>
#include <ofono/cbs.h>
#include <ofono/devinfo.h>
#include <ofono/gprs-context.h>
#include <ofono/gprs.h>
#include <ofono/netreg.h>
#include <ofono/phonebook.h>
#include <ofono/radio-settings.h>
#include <ofono/sim.h>
#include <ofono/sms.h>
#include <ofono/stk.h>
#include <ofono/ussd.h>
#include <ofono/voicecall.h>
#include <ofono/netmon.h>
#include <grilio_queue.h>
#include <grilio_request.h>
#include <grilio_parser.h>
#define RILMODEM_DRIVER "ril"
struct ril_modem {
GRilIoChannel *io;
const char *imei;
const char *imeisv;
const char *log_prefix;
const char *ecclist_file;
struct ofono_modem *ofono;
struct sailfish_cell_info *cell_info;
struct ril_radio *radio;
struct ril_data *data;
struct ril_network *network;
struct ril_sim_card *sim_card;
struct ril_sim_settings *sim_settings;
struct ril_slot_config config;
};
struct ril_oem_raw;
struct ril_oem_raw *ril_oem_raw_new(struct ril_modem *modem,
const char *log_prefix);
void ril_oem_raw_free(struct ril_oem_raw *raw);
struct ril_modem *ril_modem_create(GRilIoChannel *io, const char *log_prefix,
const char *path, const char *imei, const char *imeisv,
const char *ecclist_file, const struct ril_slot_config *config,
struct ril_radio *radio, struct ril_network *network,
struct ril_sim_card *card, struct ril_data *data,
struct ril_sim_settings *settings,
struct sailfish_cell_info *cell_info);
void ril_modem_delete(struct ril_modem *modem);
struct ofono_sim *ril_modem_ofono_sim(struct ril_modem *modem);
struct ofono_gprs *ril_modem_ofono_gprs(struct ril_modem *modem);
struct ofono_netreg *ril_modem_ofono_netreg(struct ril_modem *modem);
#define ril_modem_get_path(modem) ofono_modem_get_path((modem)->ofono)
#define ril_modem_4g_enabled(modem) ((modem)->config.enable_4g)
#define ril_modem_slot(modem) ((modem)->config.slot)
#define ril_modem_io(modem) ((modem)->io)
int ril_sim_app_type(struct ofono_sim *sim);
int ril_netreg_check_if_really_roaming(struct ofono_netreg *reg, gint status);
extern const struct ofono_call_barring_driver ril_call_barring_driver;
extern const struct ofono_call_forwarding_driver ril_call_forwarding_driver;
extern const struct ofono_call_settings_driver ril_call_settings_driver;
extern const struct ofono_call_volume_driver ril_call_volume_driver;
extern const struct ofono_cbs_driver ril_cbs_driver;
extern const struct ofono_devinfo_driver ril_devinfo_driver;
extern const struct ofono_gprs_context_driver ril_gprs_context_driver;
extern const struct ofono_gprs_driver ril_gprs_driver;
extern const struct ofono_modem_driver ril_modem_driver;
extern const struct ofono_netreg_driver ril_netreg_driver;
extern const struct ofono_phonebook_driver ril_phonebook_driver;
extern const struct ofono_radio_settings_driver ril_radio_settings_driver;
extern const struct ofono_sim_driver ril_sim_driver;
extern const struct ofono_sms_driver ril_sms_driver;
extern const struct ofono_stk_driver ril_stk_driver;
extern const struct ofono_ussd_driver ril_ussd_driver;
extern const struct ofono_voicecall_driver ril_voicecall_driver;
extern const struct ofono_netmon_driver ril_netmon_driver;
#endif /* RIL_PLUGIN_H */
/*
* Local Variables:
* mode: C
* c-basic-offset: 8
* indent-tabs-mode: t
* End:
*/

View File

@@ -0,0 +1,459 @@
/*
* oFono - Open Source Telephony - RIL-based devices
*
* Copyright (C) 2015-2017 Jolla Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "ril_radio.h"
#include "ril_util.h"
#include "ril_log.h"
#include <grilio_queue.h>
#include <grilio_request.h>
#include <grilio_parser.h>
#include <gutil_misc.h>
typedef GObjectClass RilRadioClass;
typedef struct ril_radio RilRadio;
/*
* Object states:
*
* 1. Idle (!pending && !retry)
* 2. Power on/off request pending (pending)
* 3. Power on retry has been scheduled (retry)
*/
struct ril_radio_priv {
GRilIoChannel *io;
GRilIoQueue *q;
gulong state_event_id;
char *log_prefix;
GHashTable *req_table;
guint pending_id;
guint retry_id;
guint state_changed_while_request_pending;
enum ril_radio_state last_known_state;
gboolean power_cycle;
gboolean next_state_valid;
gboolean next_state;
};
enum ril_radio_signal {
SIGNAL_STATE_CHANGED,
SIGNAL_ONLINE_CHANGED,
SIGNAL_COUNT
};
#define POWER_RETRY_SECS (1)
#define SIGNAL_STATE_CHANGED_NAME "ril-radio-state-changed"
#define SIGNAL_ONLINE_CHANGED_NAME "ril-radio-online-changed"
static guint ril_radio_signals[SIGNAL_COUNT] = { 0 };
#define NEW_SIGNAL(klass,name) \
ril_radio_signals[SIGNAL_##name##_CHANGED] = \
g_signal_new(SIGNAL_##name##_CHANGED_NAME, \
G_OBJECT_CLASS_TYPE(klass), G_SIGNAL_RUN_FIRST, \
0, NULL, NULL, NULL, G_TYPE_NONE, 0)
G_DEFINE_TYPE(RilRadio, ril_radio, G_TYPE_OBJECT)
#define RIL_RADIO_TYPE (ril_radio_get_type())
#define RIL_RADIO(obj) (G_TYPE_CHECK_INSTANCE_CAST(obj,RIL_RADIO_TYPE,RilRadio))
static void ril_radio_submit_power_request(struct ril_radio *self, gboolean on);
static inline gboolean ril_radio_power_should_be_on(struct ril_radio *self)
{
struct ril_radio_priv *priv = self->priv;
return self->online && !priv->power_cycle &&
g_hash_table_size(priv->req_table) > 0;
}
static inline gboolean ril_radio_state_off(enum ril_radio_state radio_state)
{
return radio_state == RADIO_STATE_OFF;
}
static inline gboolean ril_radio_state_on(enum ril_radio_state radio_state)
{
return !ril_radio_state_off(radio_state);
}
static inline void ril_radio_emit_signal(struct ril_radio *self,
enum ril_radio_signal id)
{
g_signal_emit(self, ril_radio_signals[id], 0);
}
static gboolean ril_radio_power_request_retry_cb(gpointer user_data)
{
struct ril_radio *self = RIL_RADIO(user_data);
struct ril_radio_priv *priv = self->priv;
DBG("%s", priv->log_prefix);
GASSERT(priv->retry_id);
priv->retry_id = 0;
ril_radio_submit_power_request(self,
ril_radio_power_should_be_on(self));
return G_SOURCE_REMOVE;
}
static void ril_radio_cancel_retry(struct ril_radio *self)
{
struct ril_radio_priv *priv = self->priv;
if (priv->retry_id) {
DBG("%sretry cancelled", priv->log_prefix);
g_source_remove(priv->retry_id);
priv->retry_id = 0;
}
}
static void ril_radio_check_state(struct ril_radio *self)
{
struct ril_radio_priv *priv = self->priv;
if (!priv->pending_id) {
gboolean should_be_on = ril_radio_power_should_be_on(self);
if (ril_radio_state_on(self->priv->last_known_state) ==
should_be_on) {
/* All is good, cancel pending retry if there is one */
ril_radio_cancel_retry(self);
} else if (priv->state_changed_while_request_pending) {
/* Hmm... RIL's reaction was inadequate, repeat */
ril_radio_submit_power_request(self, should_be_on);
} else if (!priv->retry_id) {
/* There has been no reaction so far, wait a bit */
DBG("%sretry scheduled", priv->log_prefix);
priv->retry_id = g_timeout_add_seconds(POWER_RETRY_SECS,
ril_radio_power_request_retry_cb, self);
}
}
/* Don't update public state while something is pending */
if (!priv->pending_id && !priv->retry_id &&
self->state != priv->last_known_state) {
DBG("%s%s -> %s", priv->log_prefix,
ril_radio_state_to_string(self->state),
ril_radio_state_to_string(priv->last_known_state));
self->state = priv->last_known_state;
ril_radio_emit_signal(self, SIGNAL_STATE_CHANGED);
}
}
static void ril_radio_power_request_cb(GRilIoChannel *channel, int ril_status,
const void *data, guint len, void *user_data)
{
struct ril_radio *self = RIL_RADIO(user_data);
struct ril_radio_priv *priv = self->priv;
GASSERT(priv->pending_id);
priv->pending_id = 0;
if (ril_status != RIL_E_SUCCESS) {
ofono_error("Power request failed: %s",
ril_error_to_string(ril_status));
}
if (priv->next_state_valid) {
ril_radio_submit_power_request(self, priv->next_state);
} else {
ril_radio_check_state(self);
}
}
static void ril_radio_submit_power_request(struct ril_radio *self, gboolean on)
{
/*
* RIL_REQUEST_RADIO_POWER
*
* "data" is int *
* ((int *)data)[0] is > 0 for "Radio On"
* ((int *)data)[0] is == 0 for "Radio Off"
*
* "response" is NULL
**/
GRilIoRequest *req = grilio_request_array_int32_new(1, on);
struct ril_radio_priv *priv = self->priv;
priv->next_state_valid = FALSE;
priv->next_state = on;
priv->state_changed_while_request_pending = 0;
ril_radio_cancel_retry(self);
GASSERT(!priv->pending_id);
grilio_request_set_blocking(req, TRUE);
priv->pending_id = grilio_queue_send_request_full(priv->q, req,
RIL_REQUEST_RADIO_POWER, ril_radio_power_request_cb,
NULL, self);
grilio_request_unref(req);
}
static void ril_radio_power_request(struct ril_radio *self, gboolean on,
gboolean allow_repeat)
{
struct ril_radio_priv *priv = self->priv;
const char *on_off = on ? "on" : "off";
if (priv->pending_id) {
if (allow_repeat || priv->next_state != on) {
/* Wait for the pending request to complete */
priv->next_state_valid = TRUE;
priv->next_state = on;
DBG("%s%s (queued)", priv->log_prefix, on_off);
} else {
DBG("%s%s (ignored)", priv->log_prefix, on_off);
}
} else {
DBG("%s%s", priv->log_prefix, on_off);
ril_radio_submit_power_request(self, on);
}
}
void ril_radio_confirm_power_on(struct ril_radio *self)
{
if (G_LIKELY(self) && ril_radio_power_should_be_on(self)) {
ril_radio_power_request(self, TRUE, TRUE);
}
}
void ril_radio_power_cycle(struct ril_radio *self)
{
if (G_LIKELY(self)) {
struct ril_radio_priv *priv = self->priv;
if (ril_radio_state_off(priv->last_known_state)) {
DBG("%spower is already off", priv->log_prefix);
GASSERT(!priv->power_cycle);
} else if (priv->power_cycle) {
DBG("%salready in progress", priv->log_prefix);
} else {
DBG("%sinitiated", priv->log_prefix);
priv->power_cycle = TRUE;
if (!priv->pending_id) {
ril_radio_submit_power_request(self, FALSE);
}
}
}
}
void ril_radio_power_on(struct ril_radio *self, gpointer tag)
{
if (G_LIKELY(self)) {
struct ril_radio_priv *priv = self->priv;
if (!g_hash_table_contains(priv->req_table, tag)) {
gboolean was_on = ril_radio_power_should_be_on(self);
DBG("%s%p", priv->log_prefix, tag);
g_hash_table_insert(priv->req_table, tag, tag);
if (!was_on && ril_radio_power_should_be_on(self)) {
ril_radio_power_request(self, TRUE, FALSE);
}
}
}
}
void ril_radio_power_off(struct ril_radio *self, gpointer tag)
{
if (G_LIKELY(self)) {
struct ril_radio_priv *priv = self->priv;
if (g_hash_table_remove(priv->req_table, tag)) {
DBG("%s%p", priv->log_prefix, tag);
if (!ril_radio_power_should_be_on(self)) {
/* The last one turns the lights off */
ril_radio_power_request(self, FALSE, FALSE);
}
}
}
}
void ril_radio_set_online(struct ril_radio *self, gboolean online)
{
if (G_LIKELY(self) && self->online != online) {
gboolean on, was_on = ril_radio_power_should_be_on(self);
self->online = online;
on = ril_radio_power_should_be_on(self);
if (was_on != on) {
ril_radio_power_request(self, on, FALSE);
}
ril_radio_emit_signal(self, SIGNAL_ONLINE_CHANGED);
}
}
gulong ril_radio_add_state_changed_handler(struct ril_radio *self,
ril_radio_cb_t cb, void *arg)
{
return (G_LIKELY(self) && G_LIKELY(cb)) ? g_signal_connect(self,
SIGNAL_STATE_CHANGED_NAME, G_CALLBACK(cb), arg) : 0;
}
gulong ril_radio_add_online_changed_handler(struct ril_radio *self,
ril_radio_cb_t cb, void *arg)
{
return (G_LIKELY(self) && G_LIKELY(cb)) ? g_signal_connect(self,
SIGNAL_ONLINE_CHANGED_NAME, G_CALLBACK(cb), arg) : 0;
}
void ril_radio_remove_handler(struct ril_radio *self, gulong id)
{
if (G_LIKELY(self) && G_LIKELY(id)) {
g_signal_handler_disconnect(self, id);
}
}
void ril_radio_remove_handlers(struct ril_radio *self, gulong *ids, int count)
{
gutil_disconnect_handlers(self, ids, count);
}
enum ril_radio_state ril_radio_state_parse(const void *data, guint len)
{
GRilIoParser rilp;
int radio_state;
grilio_parser_init(&rilp, data, len);
if (grilio_parser_get_int32(&rilp, &radio_state)) {
return radio_state;
} else {
ofono_error("Error parsing radio state");
return RADIO_STATE_UNAVAILABLE;
}
}
static void ril_radio_state_changed(GRilIoChannel *io, guint code,
const void *data, guint len, void *user_data)
{
struct ril_radio *self = RIL_RADIO(user_data);
enum ril_radio_state radio_state = ril_radio_state_parse(data, len);
GASSERT(code == RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED);
if (radio_state != RADIO_STATE_UNAVAILABLE) {
struct ril_radio_priv *priv = self->priv;
DBG("%s%s", priv->log_prefix,
ril_radio_state_to_string(radio_state));
GASSERT(!priv->pending_id || !priv->retry_id);
if (priv->power_cycle && ril_radio_state_off(radio_state)) {
DBG("%sswitched off for power cycle", priv->log_prefix);
priv->power_cycle = FALSE;
}
if (priv->pending_id) {
priv->state_changed_while_request_pending++;
}
priv->last_known_state = radio_state;
ril_radio_check_state(self);
}
}
struct ril_radio *ril_radio_new(GRilIoChannel *io)
{
struct ril_radio *self = g_object_new(RIL_RADIO_TYPE, NULL);
struct ril_radio_priv *priv = self->priv;
priv->io = grilio_channel_ref(io);
priv->q = grilio_queue_new(priv->io);
priv->log_prefix =
(io && io->name && io->name[0] && strcmp(io->name, "RIL")) ?
g_strconcat(io->name, " ", NULL) : g_strdup("");
DBG("%s", priv->log_prefix);
priv->state_event_id = grilio_channel_add_unsol_event_handler(priv->io,
ril_radio_state_changed,
RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED, self);
return self;
}
struct ril_radio *ril_radio_ref(struct ril_radio *self)
{
if (G_LIKELY(self)) {
g_object_ref(RIL_RADIO(self));
return self;
} else {
return NULL;
}
}
void ril_radio_unref(struct ril_radio *self)
{
if (G_LIKELY(self)) {
g_object_unref(RIL_RADIO(self));
}
}
static void ril_radio_init(struct ril_radio *self)
{
struct ril_radio_priv *priv = G_TYPE_INSTANCE_GET_PRIVATE(self,
RIL_RADIO_TYPE, struct ril_radio_priv);
self->priv = priv;
priv->req_table = g_hash_table_new_full(g_direct_hash, g_direct_equal,
NULL, NULL);
}
static void ril_radio_dispose(GObject *object)
{
struct ril_radio *self = RIL_RADIO(object);
struct ril_radio_priv *priv = self->priv;
if (priv->state_event_id) {
grilio_channel_remove_handler(priv->io, priv->state_event_id);
priv->state_event_id = 0;
}
if (priv->pending_id) {
grilio_queue_cancel_request(priv->q, priv->pending_id, FALSE);
priv->pending_id = 0;
}
priv->next_state_valid = FALSE;
ril_radio_cancel_retry(self);
grilio_queue_cancel_all(priv->q, FALSE);
G_OBJECT_CLASS(ril_radio_parent_class)->dispose(object);
}
static void ril_radio_finalize(GObject *object)
{
struct ril_radio *self = RIL_RADIO(object);
struct ril_radio_priv *priv = self->priv;
DBG("%s", priv->log_prefix);
g_free(priv->log_prefix);
grilio_channel_unref(priv->io);
grilio_queue_unref(priv->q);
g_hash_table_unref(priv->req_table);
G_OBJECT_CLASS(ril_radio_parent_class)->finalize(object);
}
static void ril_radio_class_init(RilRadioClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS(klass);
object_class->dispose = ril_radio_dispose;
object_class->finalize = ril_radio_finalize;
g_type_class_add_private(klass, sizeof(struct ril_radio_priv));
NEW_SIGNAL(klass, STATE);
NEW_SIGNAL(klass, ONLINE);
}
/*
* Local Variables:
* mode: C
* c-basic-offset: 8
* indent-tabs-mode: t
* End:
*/

View File

@@ -0,0 +1,58 @@
/*
* oFono - Open Source Telephony - RIL-based devices
*
* Copyright (C) 2015-2017 Jolla Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#ifndef RIL_RADIO_H
#define RIL_RADIO_H
#include "ril_types.h"
struct ril_radio {
GObject object;
struct ril_radio_priv *priv;
enum ril_radio_state state;
gboolean online;
};
typedef void (*ril_radio_cb_t)(struct ril_radio *radio, void *arg);
struct ril_radio *ril_radio_new(GRilIoChannel *io);
struct ril_radio *ril_radio_ref(struct ril_radio *radio);
void ril_radio_unref(struct ril_radio *radio);
void ril_radio_power_on(struct ril_radio *radio, gpointer tag);
void ril_radio_power_off(struct ril_radio *radio, gpointer tag);
void ril_radio_power_cycle(struct ril_radio *radio);
void ril_radio_confirm_power_on(struct ril_radio *radio);
void ril_radio_set_online(struct ril_radio *radio, gboolean online);
gulong ril_radio_add_state_changed_handler(struct ril_radio *radio,
ril_radio_cb_t cb, void *arg);
gulong ril_radio_add_online_changed_handler(struct ril_radio *radio,
ril_radio_cb_t cb, void *arg);
void ril_radio_remove_handler(struct ril_radio *radio, gulong id);
void ril_radio_remove_handlers(struct ril_radio *radio, gulong *ids, int n);
enum ril_radio_state ril_radio_state_parse(const void *data, guint len);
#define ril_radio_remove_all_handlers(r,ids) \
ril_radio_remove_handlers(r, ids, G_N_ELEMENTS(ids))
#endif /* RIL_RADIO_H */
/*
* Local Variables:
* mode: C
* c-basic-offset: 8
* indent-tabs-mode: t
* End:
*/

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,66 @@
/*
* oFono - Open Source Telephony - RIL-based devices
*
* Copyright (C) 2017 Jolla Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#ifndef RIL_RADIO_CAPS_H
#define RIL_RADIO_CAPS_H
#include "ril_types.h"
struct ril_data_manager;
struct ril_radio_caps;
struct ril_radio_caps_manager;
struct ril_radio_capability;
typedef void (*ril_radio_caps_manager_cb_t)(struct ril_radio_caps_manager *mgr,
void *user_data);
/* ril_radio_capability pointer is NULL if functionality is unsupported */
typedef void (*ril_radio_caps_check_cb_t)
(const struct ril_radio_capability *cap, void *user_data);
/* The check can be cancelled with grilio_channel_cancel_request */
guint ril_radio_caps_check(GRilIoChannel *io, ril_radio_caps_check_cb_t cb,
void *user_data);
/* There should be a single ril_radio_caps_manager shared by all all modems */
struct ril_radio_caps_manager *ril_radio_caps_manager_new
(struct ril_data_manager *dm);
struct ril_radio_caps_manager *ril_radio_caps_manager_ref
(struct ril_radio_caps_manager *mgr);
void ril_radio_caps_manager_unref(struct ril_radio_caps_manager *mgr);
gulong ril_radio_caps_manager_add_aborted_handler
(struct ril_radio_caps_manager *mgr,
ril_radio_caps_manager_cb_t cb, void *arg);
void ril_radio_caps_manager_remove_handler(struct ril_radio_caps_manager *mgr,
gulong id);
/* And one ril_radio_caps object per modem */
struct ril_radio_caps *ril_radio_caps_new(struct ril_radio_caps_manager *mgr,
const char *log_prefix, GRilIoChannel *io,
struct ril_data *data, struct ril_radio *radio,
struct ril_sim_card *sim, struct ril_network *net,
const struct ril_slot_config *config,
const struct ril_radio_capability *cap);
struct ril_radio_caps *ril_radio_caps_ref(struct ril_radio_caps *caps);
void ril_radio_caps_unref(struct ril_radio_caps *caps);
#endif /* RIL_RADIO_CAPS_H */
/*
* Local Variables:
* mode: C
* c-basic-offset: 8
* indent-tabs-mode: t
* End:
*/

View File

@@ -0,0 +1,194 @@
/*
* oFono - Open Source Telephony - RIL-based devices
*
* Copyright (C) 2015-2017 Jolla Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "ril_plugin.h"
#include "ril_sim_settings.h"
#include "ril_util.h"
#include "ril_log.h"
struct ril_radio_settings {
struct ofono_radio_settings *rs;
struct ril_sim_settings *settings;
const char *log_prefix;
char *allocated_log_prefix;
guint source_id;
};
struct ril_radio_settings_cbd {
struct ril_radio_settings *rsd;
union _ofono_radio_settings_cb {
ofono_radio_settings_rat_mode_set_cb_t rat_mode_set;
ofono_radio_settings_rat_mode_query_cb_t rat_mode_query;
ofono_radio_settings_available_rats_query_cb_t available_rats;
gpointer ptr;
} cb;
gpointer data;
};
#define DBG_(rsd,fmt,args...) DBG("%s" fmt, (rsd)->log_prefix, ##args)
static inline struct ril_radio_settings *ril_radio_settings_get_data(
struct ofono_radio_settings *rs)
{
return ofono_radio_settings_get_data(rs);
}
static void ril_radio_settings_later(struct ril_radio_settings *rsd,
GSourceFunc fn, void *cb, void *data)
{
struct ril_radio_settings_cbd *cbd;
cbd = g_new0(struct ril_radio_settings_cbd, 1);
cbd->rsd = rsd;
cbd->cb.ptr = cb;
cbd->data = data;
GASSERT(!rsd->source_id);
rsd->source_id = g_idle_add_full(G_PRIORITY_DEFAULT_IDLE,
fn, cbd, g_free);
}
static gboolean ril_radio_settings_set_rat_mode_cb(gpointer user_data)
{
struct ofono_error error;
struct ril_radio_settings_cbd *cbd = user_data;
struct ril_radio_settings *rsd = cbd->rsd;
GASSERT(rsd->source_id);
rsd->source_id = 0;
cbd->cb.rat_mode_set(ril_error_ok(&error), cbd->data);
return G_SOURCE_REMOVE;
}
static void ril_radio_settings_set_rat_mode(struct ofono_radio_settings *rs,
enum ofono_radio_access_mode mode,
ofono_radio_settings_rat_mode_set_cb_t cb, void *data)
{
struct ril_radio_settings *rsd = ril_radio_settings_get_data(rs);
DBG_(rsd, "%s", ofono_radio_access_mode_to_string(mode));
ril_sim_settings_set_pref_mode(rsd->settings, mode);
ril_radio_settings_later(rsd, ril_radio_settings_set_rat_mode_cb,
cb, data);
}
static gboolean ril_radio_settings_query_rat_mode_cb(gpointer user_data)
{
struct ril_radio_settings_cbd *cbd = user_data;
struct ril_radio_settings *rsd = cbd->rsd;
enum ofono_radio_access_mode mode = rsd->settings->pref_mode;
struct ofono_error error;
DBG_(rsd, "rat mode %s", ofono_radio_access_mode_to_string(mode));
GASSERT(rsd->source_id);
rsd->source_id = 0;
cbd->cb.rat_mode_query(ril_error_ok(&error), mode, cbd->data);
return G_SOURCE_REMOVE;
}
static void ril_radio_settings_query_rat_mode(struct ofono_radio_settings *rs,
ofono_radio_settings_rat_mode_query_cb_t cb, void *data)
{
struct ril_radio_settings *rsd = ril_radio_settings_get_data(rs);
DBG_(rsd, "");
ril_radio_settings_later(rsd, ril_radio_settings_query_rat_mode_cb,
cb, data);
}
static gboolean ril_radio_settings_query_available_rats_cb(gpointer data)
{
struct ofono_error error;
struct ril_radio_settings_cbd *cbd = data;
struct ril_radio_settings *rsd = cbd->rsd;
GASSERT(rsd->source_id);
rsd->source_id = 0;
cbd->cb.available_rats(ril_error_ok(&error), rsd->settings->techs,
cbd->data);
return G_SOURCE_REMOVE;
}
static void ril_radio_settings_query_available_rats(
struct ofono_radio_settings *rs,
ofono_radio_settings_available_rats_query_cb_t cb, void *data)
{
struct ril_radio_settings *rsd = ril_radio_settings_get_data(rs);
DBG_(rsd, "");
ril_radio_settings_later(rsd,
ril_radio_settings_query_available_rats_cb, cb, data);
}
static gboolean ril_radio_settings_register(gpointer user_data)
{
struct ril_radio_settings *rsd = user_data;
GASSERT(rsd->source_id);
rsd->source_id = 0;
ofono_radio_settings_register(rsd->rs);
return G_SOURCE_REMOVE;
}
static int ril_radio_settings_probe(struct ofono_radio_settings *rs,
unsigned int vendor, void *data)
{
struct ril_modem *modem = data;
struct ril_radio_settings *rsd = g_new0(struct ril_radio_settings, 1);
DBG("%s", modem->log_prefix);
rsd->rs = rs;
rsd->settings = ril_sim_settings_ref(modem->sim_settings);
rsd->source_id = g_idle_add(ril_radio_settings_register, rsd);
if (modem->log_prefix && modem->log_prefix[0]) {
rsd->log_prefix = rsd->allocated_log_prefix =
g_strconcat(modem->log_prefix, " ", NULL);
} else {
rsd->log_prefix = "";
}
ofono_radio_settings_set_data(rs, rsd);
return 0;
}
static void ril_radio_settings_remove(struct ofono_radio_settings *rs)
{
struct ril_radio_settings *rsd = ril_radio_settings_get_data(rs);
DBG_(rsd, "");
ofono_radio_settings_set_data(rs, NULL);
if (rsd->source_id) {
g_source_remove(rsd->source_id);
}
ril_sim_settings_unref(rsd->settings);
g_free(rsd->allocated_log_prefix);
g_free(rsd);
}
const struct ofono_radio_settings_driver ril_radio_settings_driver = {
.name = RILMODEM_DRIVER,
.probe = ril_radio_settings_probe,
.remove = ril_radio_settings_remove,
.query_rat_mode = ril_radio_settings_query_rat_mode,
.set_rat_mode = ril_radio_settings_set_rat_mode,
.query_available_rats = ril_radio_settings_query_available_rats
};
/*
* Local Variables:
* mode: C
* c-basic-offset: 8
* indent-tabs-mode: t
* End:
*/

1540
ofono/drivers/ril/ril_sim.c Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,694 @@
/*
* oFono - Open Source Telephony - RIL-based devices
*
* Copyright (C) 2015-2017 Jolla Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "ril_sim_card.h"
#include "ril_radio.h"
#include "ril_util.h"
#include "ril_log.h"
#include <grilio_queue.h>
#include <grilio_request.h>
#include <grilio_parser.h>
#include <gutil_misc.h>
#define UICC_SUBSCRIPTION_TIMEOUT_MS (30000)
/* SIM I/O idle timeout is measured in the number of idle loops.
* When active SIM I/O is going on, the idle loop count very rarely
* exceeds 1 between the requests, so 10 is more than enough. Idle
* loop is actually more accurate criteria than a timeout because
* it doesn't depend that much on the system load. */
#define SIM_IO_IDLE_LOOPS (10)
typedef GObjectClass RilSimCardClass;
typedef struct ril_sim_card RilSimCard;
enum ril_sim_card_event {
EVENT_SIM_STATUS_CHANGED,
EVENT_UICC_SUBSCRIPTION_STATUS_CHANGED,
EVENT_COUNT
};
struct ril_sim_card_priv {
GRilIoChannel *io;
GRilIoQueue *q;
int flags;
guint status_req_id;
guint sub_req_id;
gulong event_id[EVENT_COUNT];
guint sim_io_idle_id;
guint sim_io_idle_count;
GHashTable* sim_io_pending;
};
enum ril_sim_card_signal {
SIGNAL_STATUS_RECEIVED,
SIGNAL_STATUS_CHANGED,
SIGNAL_STATE_CHANGED,
SIGNAL_APP_CHANGED,
SIGNAL_SIM_IO_ACTIVE_CHANGED,
SIGNAL_COUNT
};
#define SIGNAL_STATUS_RECEIVED_NAME "ril-simcard-status-received"
#define SIGNAL_STATUS_CHANGED_NAME "ril-simcard-status-changed"
#define SIGNAL_STATE_CHANGED_NAME "ril-simcard-state-changed"
#define SIGNAL_APP_CHANGED_NAME "ril-simcard-app-changed"
#define SIGNAL_SIM_IO_ACTIVE_CHANGED_NAME "ril-simcard-sim-io-active-changed"
static guint ril_sim_card_signals[SIGNAL_COUNT] = { 0 };
G_DEFINE_TYPE(RilSimCard, ril_sim_card, G_TYPE_OBJECT)
#define RIL_SIMCARD_TYPE (ril_sim_card_get_type())
#define RIL_SIMCARD(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), \
RIL_SIMCARD_TYPE, RilSimCard))
#define NEW_SIGNAL(klass,name) NEW_SIGNAL_(klass,name##_CHANGED)
#define NEW_SIGNAL_(klass,name) \
ril_sim_card_signals[SIGNAL_##name] = \
g_signal_new(SIGNAL_##name##_NAME, \
G_OBJECT_CLASS_TYPE(klass), G_SIGNAL_RUN_FIRST, \
0, NULL, NULL, NULL, G_TYPE_NONE, 0)
#define RIL_SIMCARD_STATE_CHANGED (0x01)
#define RIL_SIMCARD_STATUS_CHANGED (0x02)
static gboolean ril_sim_card_app_equal(const struct ril_sim_card_app *a1,
const struct ril_sim_card_app *a2)
{
if (a1 == a2) {
return TRUE;
} else if (!a1 || !a2) {
return FALSE;
} else {
return a1->app_type == a2->app_type &&
a1->app_state == a2->app_state &&
a1->perso_substate == a2->perso_substate &&
a1->pin_replaced == a2->pin_replaced &&
a1->pin1_state == a2->pin1_state &&
a1->pin2_state == a2->pin2_state &&
!g_strcmp0(a1->aid, a2->aid) &&
!g_strcmp0(a1->label, a2->label);
}
}
static int ril_sim_card_status_compare(const struct ril_sim_card_status *s1,
const struct ril_sim_card_status *s2)
{
if (s1 == s2) {
return 0;
} else if (!s1 || !s2) {
return RIL_SIMCARD_STATE_CHANGED | RIL_SIMCARD_STATUS_CHANGED;
} else {
int diff = 0;
if (s1->card_state != s2->card_state) {
diff |= RIL_SIMCARD_STATE_CHANGED;
}
if (s1->pin_state != s2->pin_state ||
s1->gsm_umts_index != s2->gsm_umts_index ||
s1->cdma_index != s2->cdma_index ||
s1->ims_index != s2->ims_index ||
s1->num_apps != s2->num_apps) {
diff |= RIL_SIMCARD_STATUS_CHANGED;
} else {
int i;
for (i = 0; i < s1->num_apps; i++) {
if (!ril_sim_card_app_equal(s1->apps + i,
s2->apps + i)) {
diff |= RIL_SIMCARD_STATUS_CHANGED;
break;
}
}
}
return diff;
}
}
static void ril_sim_card_status_free(struct ril_sim_card_status *status)
{
if (status) {
if (status->apps) {
int i;
for (i = 0; i < status->num_apps; i++) {
g_free(status->apps[i].aid);
g_free(status->apps[i].label);
}
g_free(status->apps);
}
g_free(status);
}
}
static void ril_sim_card_subscription_done(struct ril_sim_card *self)
{
struct ril_sim_card_priv *priv = self->priv;
if (priv->sub_req_id) {
/* Some RILs never reply to SET_UICC_SUBSCRIPTION requst,
* so we better drop rather than cancel it (so that it gets
* removed from the list of pending requests) */
grilio_channel_drop_request(priv->io, priv->sub_req_id);
priv->sub_req_id = 0;
}
grilio_queue_transaction_finish(priv->q);
}
static void ril_sim_card_subscribe_cb(GRilIoChannel* io, int status,
const void* data, guint len, void* user_data)
{
struct ril_sim_card *self = RIL_SIMCARD(user_data);
struct ril_sim_card_priv *priv = self->priv;
GASSERT(status == GRILIO_STATUS_OK);
GASSERT(priv->sub_req_id);
priv->sub_req_id = 0;
DBG("UICC subscription OK for slot %u", self->slot);
ril_sim_card_subscription_done(self);
}
static void ril_sim_card_subscribe(struct ril_sim_card *self, int app_index,
enum ril_uicc_subscription_action sub_action)
{
struct ril_sim_card_priv *priv = self->priv;
GRilIoRequest *req = grilio_request_sized_new(16);
const guint sub_id = self->slot;
guint code;
DBG("%u,%d,%u,%d", self->slot, app_index, sub_id, sub_action);
grilio_request_append_int32(req, self->slot);
grilio_request_append_int32(req, app_index);
grilio_request_append_int32(req, sub_id);
grilio_request_append_int32(req, sub_action);
grilio_request_set_retry(req, 0, -1);
grilio_request_set_timeout(req, UICC_SUBSCRIPTION_TIMEOUT_MS);
code = (priv->io->ril_version <= 9 &&
(priv->flags & RIL_SIM_CARD_V9_UICC_SUBSCRIPTION_WORKAROUND)) ?
RIL_REQUEST_V9_SET_UICC_SUBSCRIPTION :
RIL_REQUEST_SET_UICC_SUBSCRIPTION;
if (priv->sub_req_id) {
/* Some RILs never reply to SET_UICC_SUBSCRIPTION requst,
* so we better drop rather than cancel it (so that it gets
* removed from the list of pending requests) */
grilio_channel_drop_request(priv->io, priv->sub_req_id);
}
/* Don't allow any requests other that GET_SIM_STATUS until
* we are done with the subscription */
grilio_queue_transaction_start(priv->q);
priv->sub_req_id = grilio_queue_send_request_full(priv->q,
req, code, ril_sim_card_subscribe_cb, NULL, self);
grilio_request_unref(req);
}
static int ril_sim_card_select_app(const struct ril_sim_card_status *status)
{
int i, selected_app = -1;
for (i = 0; i < status->num_apps; i++) {
const int type = status->apps[i].app_type;
if (type == RIL_APPTYPE_USIM || type == RIL_APPTYPE_RUIM) {
selected_app = i;
break;
} else if (type != RIL_APPTYPE_UNKNOWN && selected_app == -1) {
selected_app = i;
}
}
DBG("%d", selected_app);
return selected_app;
}
static void ril_sim_card_update_app(struct ril_sim_card *self)
{
const struct ril_sim_card_app *old_app = self->app;
const struct ril_sim_card_status *status = self->status;
int app_index;
if (status->card_state == RIL_CARDSTATE_PRESENT) {
if (status->gsm_umts_index >= 0 &&
status->gsm_umts_index < status->num_apps) {
app_index = status->gsm_umts_index;
ril_sim_card_subscription_done(self);
} else {
app_index = ril_sim_card_select_app(status);
if (app_index >= 0) {
ril_sim_card_subscribe(self, app_index,
RIL_UICC_SUBSCRIPTION_ACTIVATE);
}
}
} else {
app_index = -1;
ril_sim_card_subscription_done(self);
}
if (app_index >= 0 &&
status->apps[app_index].app_type != RIL_APPTYPE_UNKNOWN) {
self->app = status->apps + app_index;
} else {
self->app = NULL;
}
if (!ril_sim_card_app_equal(old_app, self->app)) {
g_signal_emit(self, ril_sim_card_signals
[SIGNAL_APP_CHANGED], 0);
}
}
static void ril_sim_card_update_status(struct ril_sim_card *self,
struct ril_sim_card_status *status)
{
const int diff = ril_sim_card_status_compare(self->status, status);
if (diff) {
struct ril_sim_card_status *old_status = self->status;
self->status = status;
ril_sim_card_update_app(self);
g_signal_emit(self, ril_sim_card_signals
[SIGNAL_STATUS_RECEIVED], 0);
if (diff & RIL_SIMCARD_STATUS_CHANGED) {
DBG("status changed");
g_signal_emit(self, ril_sim_card_signals
[SIGNAL_STATUS_CHANGED], 0);
}
if (diff & RIL_SIMCARD_STATE_CHANGED) {
DBG("state changed");
g_signal_emit(self, ril_sim_card_signals
[SIGNAL_STATE_CHANGED], 0);
}
ril_sim_card_status_free(old_status);
} else {
ril_sim_card_status_free(status);
g_signal_emit(self, ril_sim_card_signals
[SIGNAL_STATUS_RECEIVED], 0);
}
}
static gboolean ril_sim_card_app_parse(GRilIoParser *rilp,
struct ril_sim_card_app *app)
{
gint32 app_type, app_state, perso_substate;
gint32 pin_replaced, pin1_state, pin2_state;
grilio_parser_get_int32(rilp, &app_type);
grilio_parser_get_int32(rilp, &app_state);
/*
* Consider RIL_APPSTATE_ILLEGAL also READY. Even if app state is
* RIL_APPSTATE_ILLEGAL (-1), ICC operations must be permitted.
* Network access requests will anyway be rejected and ME will be
* in limited service.
*/
if (app_state == RIL_APPSTATE_ILLEGAL) {
DBG("RIL_APPSTATE_ILLEGAL => RIL_APPSTATE_READY");
app_state = RIL_APPSTATE_READY;
}
grilio_parser_get_int32(rilp, &perso_substate);
app->aid = grilio_parser_get_utf8(rilp);
app->label = grilio_parser_get_utf8(rilp);
if (grilio_parser_get_int32(rilp, &pin_replaced) &&
grilio_parser_get_int32(rilp, &pin1_state) &&
grilio_parser_get_int32(rilp, &pin2_state)) {
app->app_type = app_type;
app->app_state = app_state;
app->perso_substate = perso_substate;
app->pin_replaced = pin_replaced;
app->pin1_state = pin1_state;
app->pin2_state = pin2_state;
return TRUE;
}
return FALSE;
}
static struct ril_sim_card_status *ril_sim_card_status_parse(const void *data,
guint len)
{
GRilIoParser rilp;
gint32 card_state, pin_state, gsm_umts_index, cdma_index;
gint32 ims_index, num_apps;
grilio_parser_init(&rilp, data, len);
if (!grilio_parser_get_int32(&rilp, &card_state) ||
!grilio_parser_get_int32(&rilp, &pin_state) ||
!grilio_parser_get_int32(&rilp, &gsm_umts_index) ||
!grilio_parser_get_int32(&rilp, &cdma_index) ||
!grilio_parser_get_int32(&rilp, &ims_index) ||
!grilio_parser_get_int32(&rilp, &num_apps)) {
ofono_error("Failed to parse SIM card status request");
return NULL;
} else if (num_apps < 0 || num_apps > RIL_CARD_MAX_APPS) {
ofono_error("Invalid SIM app count %d", num_apps);
return NULL;
} else {
int i;
struct ril_sim_card_status *status =
g_new0(struct ril_sim_card_status, 1);
DBG("card_state=%d, universal_pin_state=%d, gsm_umts_index=%d, "
"cdma_index=%d, ims_index=%d, num_apps=%d",
card_state, pin_state, gsm_umts_index, cdma_index,
ims_index, num_apps);
status->card_state = card_state;
status->pin_state = pin_state;
status->gsm_umts_index = gsm_umts_index;
status->cdma_index = cdma_index;
status->ims_index = ims_index;
status->num_apps = num_apps;
if (num_apps > 0) {
status->apps =
g_new0(struct ril_sim_card_app, num_apps);
}
for (i = 0; i < num_apps; i++) {
struct ril_sim_card_app *app = status->apps + i;
if (ril_sim_card_app_parse(&rilp, app)) {
DBG("app[%d]: type=%d, state=%d, "
"perso_substate=%d, aid_ptr=%s, "
"label=%s, pin1_replaced=%d, pin1=%d, "
"pin2=%d", i, app->app_type,
app->app_state, app->perso_substate,
app->aid, app->label,
app->pin_replaced, app->pin1_state,
app->pin2_state);
} else {
break;
}
}
if (i == num_apps) {
GASSERT(grilio_parser_at_end(&rilp));
return status;
} else {
ril_sim_card_status_free(status);
return NULL;
}
}
}
static void ril_sim_card_status_cb(GRilIoChannel *io, int ril_status,
const void *data, guint len, void *user_data)
{
struct ril_sim_card *self = RIL_SIMCARD(user_data);
struct ril_sim_card_priv *priv = self->priv;
GASSERT(priv->status_req_id);
priv->status_req_id = 0;
if (ril_status == RIL_E_SUCCESS) {
struct ril_sim_card_status *status =
ril_sim_card_status_parse(data, len);
if (status) {
ril_sim_card_update_status(self, status);
}
}
}
void ril_sim_card_request_status(struct ril_sim_card *self)
{
if (G_LIKELY(self)) {
struct ril_sim_card_priv *priv = self->priv;
if (priv->status_req_id) {
/* Retry right away, don't wait for retry
* timeout to expire */
grilio_channel_retry_request(priv->io,
priv->status_req_id);
} else {
GRilIoRequest* req = grilio_request_new();
grilio_request_set_retry(req, RIL_RETRY_SECS*1000, -1);
priv->status_req_id =
grilio_queue_send_request_full(priv->q,
req, RIL_REQUEST_GET_SIM_STATUS,
ril_sim_card_status_cb, NULL, self);
grilio_request_unref(req);
}
}
}
static void ril_sim_card_update_sim_io_active(struct ril_sim_card *self)
{
/* SIM I/O is considered active for certain period of time after
* the last request has completed. That's because SIM_IO requests
* are usually submitted in large quantities and quick succession.
* Some RILs don't like being bothered while they are doing SIM I/O
* and some time after that too. That sucks but what else can we
* do about it? */
struct ril_sim_card_priv *priv = self->priv;
const gboolean active = priv->sim_io_idle_id ||
g_hash_table_size(priv->sim_io_pending);
if (self->sim_io_active != active) {
self->sim_io_active = active;
DBG("SIM I/O for slot %u is %sactive", self->slot,
active ? "" : "in");
g_signal_emit(self, ril_sim_card_signals
[SIGNAL_SIM_IO_ACTIVE_CHANGED], 0);
}
}
void ril_sim_card_sim_io_started(struct ril_sim_card *self, guint id)
{
if (G_LIKELY(self) && G_LIKELY(id)) {
struct ril_sim_card_priv *priv = self->priv;
gpointer key = GINT_TO_POINTER(id);
g_hash_table_insert(priv->sim_io_pending, key, key);
if (priv->sim_io_idle_id) {
g_source_remove(priv->sim_io_idle_id);
priv->sim_io_idle_id = 0;
priv->sim_io_idle_count = 0;
}
ril_sim_card_update_sim_io_active(self);
}
}
static gboolean ril_sim_card_sim_io_idle_cb(gpointer user_data)
{
struct ril_sim_card *self = RIL_SIMCARD(user_data);
struct ril_sim_card_priv *priv = self->priv;
if (++(priv->sim_io_idle_count) >= SIM_IO_IDLE_LOOPS) {
priv->sim_io_idle_id = 0;
priv->sim_io_idle_count = 0;
ril_sim_card_update_sim_io_active(self);
return G_SOURCE_REMOVE;
} else {
return G_SOURCE_CONTINUE;
}
}
void ril_sim_card_sim_io_finished(struct ril_sim_card *self, guint id)
{
if (G_LIKELY(self) && G_LIKELY(id)) {
struct ril_sim_card_priv *priv = self->priv;
gpointer key = GINT_TO_POINTER(id);
if (g_hash_table_remove(priv->sim_io_pending, key) &&
!g_hash_table_size(priv->sim_io_pending)) {
/* Reset the idle loop count */
if (priv->sim_io_idle_id) {
g_source_remove(priv->sim_io_idle_id);
priv->sim_io_idle_count = 0;
}
priv->sim_io_idle_id =
g_idle_add(ril_sim_card_sim_io_idle_cb, self);
}
ril_sim_card_update_sim_io_active(self);
}
}
static void ril_sim_card_status_changed(GRilIoChannel *io, guint code,
const void *data, guint len, void *user_data)
{
struct ril_sim_card *self = RIL_SIMCARD(user_data);
ril_sim_card_request_status(self);
}
struct ril_sim_card *ril_sim_card_new(GRilIoChannel *io, guint slot, int flags)
{
struct ril_sim_card *self = g_object_new(RIL_SIMCARD_TYPE, NULL);
struct ril_sim_card_priv *priv = self->priv;
/*
* We need to know the RIL version (for UICC subscription hack),
* so we must be connected. The caller is supposed to make sure
* that we get connected first.
*/
DBG("%u", slot);
GASSERT(io->connected);
self->slot = slot;
priv->io = grilio_channel_ref(io);
priv->q = grilio_queue_new(io);
priv->flags = flags;
priv->event_id[EVENT_SIM_STATUS_CHANGED] =
grilio_channel_add_unsol_event_handler(priv->io,
ril_sim_card_status_changed,
RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED, self);
priv->event_id[EVENT_UICC_SUBSCRIPTION_STATUS_CHANGED] =
grilio_channel_add_unsol_event_handler(priv->io,
ril_sim_card_status_changed,
RIL_UNSOL_UICC_SUBSCRIPTION_STATUS_CHANGED, self);
ril_sim_card_request_status(self);
return self;
}
struct ril_sim_card *ril_sim_card_ref(struct ril_sim_card *self)
{
if (G_LIKELY(self)) {
g_object_ref(RIL_SIMCARD(self));
return self;
} else {
return NULL;
}
}
void ril_sim_card_unref(struct ril_sim_card *self)
{
if (G_LIKELY(self)) {
g_object_unref(RIL_SIMCARD(self));
}
}
gboolean ril_sim_card_ready(struct ril_sim_card *self)
{
return self && self->app &&
((self->app->app_state == RIL_APPSTATE_READY) ||
(self->app->app_state == RIL_APPSTATE_SUBSCRIPTION_PERSO &&
self->app->perso_substate == RIL_PERSOSUBSTATE_READY));
}
gulong ril_sim_card_add_status_received_handler(struct ril_sim_card *self,
ril_sim_card_cb_t cb, void *arg)
{
return (G_LIKELY(self) && G_LIKELY(cb)) ? g_signal_connect(self,
SIGNAL_STATUS_RECEIVED_NAME, G_CALLBACK(cb), arg) : 0;
}
gulong ril_sim_card_add_status_changed_handler(struct ril_sim_card *self,
ril_sim_card_cb_t cb, void *arg)
{
return (G_LIKELY(self) && G_LIKELY(cb)) ? g_signal_connect(self,
SIGNAL_STATUS_CHANGED_NAME, G_CALLBACK(cb), arg) : 0;
}
gulong ril_sim_card_add_state_changed_handler(struct ril_sim_card *self,
ril_sim_card_cb_t cb, void *arg)
{
return (G_LIKELY(self) && G_LIKELY(cb)) ? g_signal_connect(self,
SIGNAL_STATE_CHANGED_NAME, G_CALLBACK(cb), arg) : 0;
}
gulong ril_sim_card_add_app_changed_handler(struct ril_sim_card *self,
ril_sim_card_cb_t cb, void *arg)
{
return (G_LIKELY(self) && G_LIKELY(cb)) ? g_signal_connect(self,
SIGNAL_APP_CHANGED_NAME, G_CALLBACK(cb), arg) : 0;
}
gulong ril_sim_card_add_sim_io_active_changed_handler(struct ril_sim_card *self,
ril_sim_card_cb_t cb, void *arg)
{
return (G_LIKELY(self) && G_LIKELY(cb)) ? g_signal_connect(self,
SIGNAL_SIM_IO_ACTIVE_CHANGED_NAME, G_CALLBACK(cb), arg) : 0;
}
void ril_sim_card_remove_handler(struct ril_sim_card *self, gulong id)
{
if (G_LIKELY(self) && G_LIKELY(id)) {
g_signal_handler_disconnect(self, id);
}
}
void ril_sim_card_remove_handlers(struct ril_sim_card *self, gulong *ids, int n)
{
gutil_disconnect_handlers(self, ids, n);
}
static void ril_sim_card_init(struct ril_sim_card *self)
{
struct ril_sim_card_priv *priv = G_TYPE_INSTANCE_GET_PRIVATE(self,
RIL_SIMCARD_TYPE, struct ril_sim_card_priv);
self->priv = priv;
priv->sim_io_pending = g_hash_table_new(g_direct_hash, g_direct_equal);
}
static void ril_sim_card_dispose(GObject *object)
{
struct ril_sim_card *self = RIL_SIMCARD(object);
struct ril_sim_card_priv *priv = self->priv;
grilio_channel_remove_handlers(priv->io, priv->event_id, EVENT_COUNT);
grilio_queue_cancel_all(priv->q, TRUE);
G_OBJECT_CLASS(ril_sim_card_parent_class)->dispose(object);
}
static void ril_sim_card_finalize(GObject *object)
{
struct ril_sim_card *self = RIL_SIMCARD(object);
struct ril_sim_card_priv *priv = self->priv;
if (priv->sim_io_idle_id) {
g_source_remove(priv->sim_io_idle_id);
}
g_hash_table_destroy(priv->sim_io_pending);
grilio_channel_unref(priv->io);
grilio_queue_unref(priv->q);
ril_sim_card_status_free(self->status);
G_OBJECT_CLASS(ril_sim_card_parent_class)->finalize(object);
}
static void ril_sim_card_class_init(RilSimCardClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS(klass);
object_class->dispose = ril_sim_card_dispose;
object_class->finalize = ril_sim_card_finalize;
g_type_class_add_private(klass, sizeof(struct ril_sim_card_priv));
NEW_SIGNAL_(klass,STATUS_RECEIVED);
NEW_SIGNAL(klass,STATUS);
NEW_SIGNAL(klass,STATE);
NEW_SIGNAL(klass,APP);
NEW_SIGNAL(klass,SIM_IO_ACTIVE);
}
/*
* Local Variables:
* mode: C
* c-basic-offset: 8
* indent-tabs-mode: t
* End:
*/

View File

@@ -0,0 +1,89 @@
/*
* oFono - Open Source Telephony - RIL-based devices
*
* Copyright (C) 2015-2017 Jolla Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#ifndef RIL_SIM_CARD_H
#define RIL_SIM_CARD_H
#include "ril_types.h"
struct ril_sim_card_app {
enum ril_app_type app_type;
enum ril_app_state app_state;
enum ril_perso_substate perso_substate;
char *aid;
char *label;
guint pin_replaced;
enum ril_pin_state pin1_state;
enum ril_pin_state pin2_state;
};
struct ril_sim_card_status {
enum ril_card_state card_state;
enum ril_pin_state pin_state;
int gsm_umts_index;
int cdma_index;
int ims_index;
int num_apps;
struct ril_sim_card_app *apps;
};
struct ril_sim_card {
GObject object;
struct ril_sim_card_priv *priv;
struct ril_sim_card_status *status;
const struct ril_sim_card_app *app;
gboolean sim_io_active;
guint slot;
};
typedef void (*ril_sim_card_cb_t)(struct ril_sim_card *sc, void *arg);
/* Flags for ril_sim_card_new */
#define RIL_SIM_CARD_V9_UICC_SUBSCRIPTION_WORKAROUND (0x01)
struct ril_sim_card *ril_sim_card_new(GRilIoChannel *io, guint slot, int flags);
struct ril_sim_card *ril_sim_card_ref(struct ril_sim_card *sc);
void ril_sim_card_unref(struct ril_sim_card *sc);
void ril_sim_card_request_status(struct ril_sim_card *sc);
void ril_sim_card_sim_io_started(struct ril_sim_card *sc, guint id);
void ril_sim_card_sim_io_finished(struct ril_sim_card *sc, guint id);
gboolean ril_sim_card_ready(struct ril_sim_card *sc);
gulong ril_sim_card_add_status_received_handler(struct ril_sim_card *sc,
ril_sim_card_cb_t cb, void *arg);
gulong ril_sim_card_add_status_changed_handler(struct ril_sim_card *sc,
ril_sim_card_cb_t cb, void *arg);
gulong ril_sim_card_add_state_changed_handler(struct ril_sim_card *sc,
ril_sim_card_cb_t cb, void *arg);
gulong ril_sim_card_add_app_changed_handler(struct ril_sim_card *sc,
ril_sim_card_cb_t cb, void *arg);
gulong ril_sim_card_add_sim_io_active_changed_handler(struct ril_sim_card *sc,
ril_sim_card_cb_t cb, void *arg);
void ril_sim_card_remove_handler(struct ril_sim_card *sc, gulong id);
void ril_sim_card_remove_handlers(struct ril_sim_card *sc, gulong *ids, int n);
/* Inline wrappers */
static inline enum ril_app_type
ril_sim_card_app_type(struct ril_sim_card *sc)
{ return (sc && sc->app) ? sc->app->app_type : RIL_APPTYPE_UNKNOWN; }
#endif /* RIL_SIM_CARD_H */
/*
* Local Variables:
* mode: C
* c-basic-offset: 8
* indent-tabs-mode: t
* End:
*/

View File

@@ -0,0 +1,196 @@
/*
* oFono - Open Source Telephony - RIL-based devices
*
* Copyright (C) 2016-2017 Jolla Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "ril_sim_settings.h"
#include "ril_log.h"
#include "sailfish_watch.h"
#include <gutil_misc.h>
#define RIL_PREF_MODE_DEFAULT(self) (\
((self)->techs & OFONO_RADIO_ACCESS_MODE_LTE) ? \
OFONO_RADIO_ACCESS_MODE_LTE : \
((self)->techs & OFONO_RADIO_ACCESS_MODE_UMTS) ? \
OFONO_RADIO_ACCESS_MODE_UMTS : \
OFONO_RADIO_ACCESS_MODE_GSM)
typedef GObjectClass RilSimSettingsClass;
typedef struct ril_sim_settings RilSimSettings;
enum sailfish_watch_events {
WATCH_EVENT_IMSI,
WATCH_EVENT_COUNT
};
struct ril_sim_settings_priv {
gulong watch_event_id[WATCH_EVENT_COUNT];
struct sailfish_watch *watch;
char *imsi;
};
enum ril_sim_settings_signal {
SIGNAL_IMSI_CHANGED,
SIGNAL_PREF_MODE_CHANGED,
SIGNAL_COUNT
};
#define SIGNAL_IMSI_CHANGED_NAME "ril-sim-settings-imsi-changed"
#define SIGNAL_PREF_MODE_CHANGED_NAME "ril-sim-settings-pref-mode-changed"
static guint ril_sim_settings_signals[SIGNAL_COUNT] = { 0 };
G_DEFINE_TYPE(RilSimSettings, ril_sim_settings, G_TYPE_OBJECT)
#define RIL_SIM_SETTINGS_TYPE (ril_sim_settings_get_type())
#define RIL_SIM_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),\
RIL_SIM_SETTINGS_TYPE, RilSimSettings))
#define NEW_SIGNAL(klass,name) \
ril_sim_settings_signals[SIGNAL_##name##_CHANGED] = \
g_signal_new(SIGNAL_##name##_CHANGED_NAME, \
G_OBJECT_CLASS_TYPE(klass), G_SIGNAL_RUN_FIRST, \
0, NULL, NULL, NULL, G_TYPE_NONE, 0)
/* Skip the leading slash from the modem path: */
#define DBG_(obj,fmt,args...) DBG("%s " fmt, (obj)->path+1, ##args)
static void ril_sim_settings_signal_emit(struct ril_sim_settings *self,
enum ril_sim_settings_signal id)
{
g_signal_emit(self, ril_sim_settings_signals[id], 0);
}
void ril_sim_settings_set_pref_mode(struct ril_sim_settings *self,
enum ofono_radio_access_mode mode)
{
if (G_LIKELY(self) && self->pref_mode != mode) {
self->pref_mode = mode;
ril_sim_settings_signal_emit(self, SIGNAL_PREF_MODE_CHANGED);
}
}
static void ril_sim_settings_imsi_changed(struct sailfish_watch *watch,
void *user_data)
{
struct ril_sim_settings *self = RIL_SIM_SETTINGS(user_data);
struct ril_sim_settings_priv *priv = self->priv;
if (g_strcmp0(priv->imsi, watch->imsi)) {
g_free(priv->imsi);
self->imsi = priv->imsi = g_strdup(watch->imsi);
ril_sim_settings_signal_emit(self, SIGNAL_IMSI_CHANGED);
}
}
struct ril_sim_settings *ril_sim_settings_new(const char *path,
enum ofono_radio_access_mode techs)
{
struct ril_sim_settings *self = NULL;
if (G_LIKELY(path)) {
struct ril_sim_settings_priv *priv;
self = g_object_new(RIL_SIM_SETTINGS_TYPE, NULL);
priv = self->priv;
self->techs = techs;
self->pref_mode = RIL_PREF_MODE_DEFAULT(self);
priv->watch = sailfish_watch_new(path);
priv->watch_event_id[WATCH_EVENT_IMSI] =
sailfish_watch_add_imsi_changed_handler(priv->watch,
ril_sim_settings_imsi_changed, self);
self->imsi = priv->imsi = g_strdup(priv->watch->imsi);
}
return self;
}
struct ril_sim_settings *ril_sim_settings_ref(struct ril_sim_settings *self)
{
if (G_LIKELY(self)) {
g_object_ref(RIL_SIM_SETTINGS(self));
return self;
} else {
return NULL;
}
}
void ril_sim_settings_unref(struct ril_sim_settings *self)
{
if (G_LIKELY(self)) {
g_object_unref(RIL_SIM_SETTINGS(self));
}
}
gulong ril_sim_settings_add_imsi_changed_handler(struct ril_sim_settings *self,
ril_sim_settings_cb_t cb, void *arg)
{
return (G_LIKELY(self) && G_LIKELY(cb)) ? g_signal_connect(self,
SIGNAL_IMSI_CHANGED_NAME, G_CALLBACK(cb), arg) : 0;
}
gulong ril_sim_settings_add_pref_mode_changed_handler(
struct ril_sim_settings *self,
ril_sim_settings_cb_t cb, void *arg)
{
return (G_LIKELY(self) && G_LIKELY(cb)) ? g_signal_connect(self,
SIGNAL_PREF_MODE_CHANGED_NAME, G_CALLBACK(cb), arg) : 0;
}
void ril_sim_settings_remove_handler(struct ril_sim_settings *self, gulong id)
{
if (G_LIKELY(self) && G_LIKELY(id)) {
g_signal_handler_disconnect(self, id);
}
}
void ril_sim_settings_remove_handlers(struct ril_sim_settings *self,
gulong *ids, int count)
{
gutil_disconnect_handlers(self, ids, count);
}
static void ril_sim_settings_init(struct ril_sim_settings *self)
{
self->priv = G_TYPE_INSTANCE_GET_PRIVATE(self, RIL_SIM_SETTINGS_TYPE,
struct ril_sim_settings_priv);
}
static void ril_sim_settings_finalize(GObject *object)
{
struct ril_sim_settings *self = RIL_SIM_SETTINGS(object);
struct ril_sim_settings_priv *priv = self->priv;
sailfish_watch_remove_all_handlers(priv->watch, priv->watch_event_id);
sailfish_watch_unref(priv->watch);
g_free(priv->imsi);
G_OBJECT_CLASS(ril_sim_settings_parent_class)->finalize(object);
}
static void ril_sim_settings_class_init(RilSimSettingsClass *klass)
{
G_OBJECT_CLASS(klass)->finalize = ril_sim_settings_finalize;
g_type_class_add_private(klass, sizeof(struct ril_sim_settings_priv));
NEW_SIGNAL(klass, IMSI);
NEW_SIGNAL(klass, PREF_MODE);
}
/*
* Local Variables:
* mode: C
* c-basic-offset: 8
* indent-tabs-mode: t
* End:
*/

View File

@@ -0,0 +1,55 @@
/*
* oFono - Open Source Telephony - RIL-based devices
*
* Copyright (C) 2016-2017 Jolla Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#ifndef RIL_SIM_SETTINGS_H
#define RIL_SIM_SETTINGS_H
#include "ril_types.h"
struct ril_sim_settings_priv;
struct ril_sim_settings {
GObject object;
struct ril_sim_settings_priv *priv;
const char *imsi;
enum ofono_radio_access_mode techs;
enum ofono_radio_access_mode pref_mode;
};
typedef void (*ril_sim_settings_cb_t)(struct ril_sim_settings *s, void *arg);
struct ril_sim_settings *ril_sim_settings_new(const char *path,
enum ofono_radio_access_mode techs);
struct ril_sim_settings *ril_sim_settings_ref(struct ril_sim_settings *s);
void ril_sim_settings_unref(struct ril_sim_settings *s);
void ril_sim_settings_set_pref_mode(struct ril_sim_settings *s,
enum ofono_radio_access_mode mode);
gulong ril_sim_settings_add_imsi_changed_handler(struct ril_sim_settings *s,
ril_sim_settings_cb_t cb, void *arg);
gulong ril_sim_settings_add_pref_mode_changed_handler(struct ril_sim_settings *s,
ril_sim_settings_cb_t cb, void *arg);
void ril_sim_settings_remove_handler(struct ril_sim_settings *s, gulong id);
void ril_sim_settings_remove_handlers(struct ril_sim_settings *s, gulong *ids,
int count);
#endif /* RIL_SIM_SETTINGS_H */
/*
* Local Variables:
* mode: C
* c-basic-offset: 8
* indent-tabs-mode: t
* End:
*/

516
ofono/drivers/ril/ril_sms.c Normal file
View File

@@ -0,0 +1,516 @@
/*
* oFono - Open Source Telephony - RIL-based devices
*
* Copyright (C) 2015-2017 Jolla Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "ril_plugin.h"
#include "ril_util.h"
#include "ril_log.h"
#include "smsutil.h"
#include "util.h"
#include "simutil.h"
#define RIL_SMS_ACK_RETRY_MS 1000
#define RIL_SMS_ACK_RETRY_COUNT 10
#define SIM_EFSMS_FILEID 0x6F3C
#define EFSMS_LENGTH 176
#define TYPE_LOCAL 129
#define TYPE_INTERNATIONAL 145
static unsigned char sim_path[4] = {0x3F, 0x00, 0x7F, 0x10};
enum ril_sms_events {
SMS_EVENT_NEW_SMS,
SMS_EVENT_NEW_STATUS_REPORT,
SMS_EVENT_NEW_SMS_ON_SIM,
SMS_EVENT_COUNT
};
struct ril_sms {
GRilIoChannel *io;
GRilIoQueue *q;
struct ril_modem *modem;
struct ofono_sms *sms;
struct ofono_sim_context *sim_context;
gulong event_id[SMS_EVENT_COUNT];
guint timer_id;
};
struct ril_sms_cbd {
union _ofono_sms_cb {
ofono_sms_sca_set_cb_t sca_set;
ofono_sms_sca_query_cb_t sca_query;
ofono_sms_submit_cb_t submit;
gpointer ptr;
} cb;
gpointer data;
};
struct ril_sms_on_sim_req {
struct ril_sms *sd;
int record;
};
#define ril_sms_cbd_free g_free
#define ril_sms_on_sim_req_free g_free
static inline struct ril_sms *ril_sms_get_data(struct ofono_sms *sms)
{
return ofono_sms_get_data(sms);
}
struct ril_sms_cbd *ril_sms_cbd_new(struct ril_sms *sd, void *cb, void *data)
{
struct ril_sms_cbd *cbd = g_new0(struct ril_sms_cbd, 1);
cbd->cb.ptr = cb;
cbd->data = data;
return cbd;
}
struct ril_sms_on_sim_req *ril_sms_on_sim_req_new(struct ril_sms *sd, int rec)
{
struct ril_sms_on_sim_req *cbd = g_new0(struct ril_sms_on_sim_req, 1);
cbd->sd = sd;
cbd->record = rec;
return cbd;
}
static void ril_sms_sca_set_cb(GRilIoChannel *io, int status,
const void *data, guint len, void *user_data)
{
struct ofono_error error;
struct ril_sms_cbd *cbd = user_data;
ofono_sms_sca_set_cb_t cb = cbd->cb.sca_set;
if (status == RIL_E_SUCCESS) {
cb(ril_error_ok(&error), cbd->data);
} else {
ofono_error("csca setting failed");
cb(ril_error_failure(&error), cbd->data);
}
}
static void ril_sms_sca_set(struct ofono_sms *sms,
const struct ofono_phone_number *sca,
ofono_sms_sca_set_cb_t cb, void *data)
{
struct ril_sms *sd = ril_sms_get_data(sms);
GRilIoRequest *req = grilio_request_new();
char number[OFONO_MAX_PHONE_NUMBER_LENGTH + 4];
if (sca->type == TYPE_LOCAL) {
snprintf(number, sizeof(number), "\"%s\"", sca->number);
} else {
snprintf(number, sizeof(number), "\"+%s\"", sca->number);
}
DBG("Setting sca: %s", number);
grilio_request_append_utf8(req, number);
grilio_queue_send_request_full(sd->q, req,
RIL_REQUEST_SET_SMSC_ADDRESS, ril_sms_sca_set_cb,
ril_sms_cbd_free, ril_sms_cbd_new(sd, cb, data));
grilio_request_unref(req);
}
static void ril_sms_sca_query_cb(GRilIoChannel *io, int status,
const void *data, guint len, void *user_data)
{
struct ril_sms_cbd *cbd = user_data;
ofono_sms_sca_query_cb_t cb = cbd->cb.sca_query;
struct ofono_error error;
GRilIoParser rilp;
gchar *temp_buf;
if (status != RIL_E_SUCCESS) {
ofono_error("csca query failed");
cb(ril_error_failure(&error), NULL, cbd->data);
return;
}
grilio_parser_init(&rilp, data, len);
temp_buf = grilio_parser_get_utf8(&rilp);
if (temp_buf) {
/* RIL gives address in quotes */
gchar *number = strtok(temp_buf, "\"");
struct ofono_phone_number sca;
strncpy(sca.number, number, OFONO_MAX_PHONE_NUMBER_LENGTH);
sca.number[OFONO_MAX_PHONE_NUMBER_LENGTH] = '\0';
if (sca.number[0] == '+') {
number = number + 1;
sca.type = TYPE_INTERNATIONAL;
} else {
sca.type = TYPE_LOCAL;
}
DBG("csca_query_cb: %s, %d", sca.number, sca.type);
cb(ril_error_ok(&error), &sca, cbd->data);
g_free(temp_buf);
} else {
ofono_error("return value invalid");
cb(ril_error_failure(&error), NULL, cbd->data);
}
}
static void ril_sms_sca_query(struct ofono_sms *sms,
ofono_sms_sca_query_cb_t cb, void *data)
{
struct ril_sms *sd = ril_sms_get_data(sms);
DBG("Sending csca_query");
grilio_queue_send_request_full(sd->q, NULL,
RIL_REQUEST_GET_SMSC_ADDRESS, ril_sms_sca_query_cb,
ril_sms_cbd_free, ril_sms_cbd_new(sd, cb, data));
}
static void ril_sms_submit_cb(GRilIoChannel *io, int status,
const void *data, guint len, void *user_data)
{
struct ril_sms_cbd *cbd = user_data;
ofono_sms_submit_cb_t cb = cbd->cb.submit;
struct ofono_error error;
int mr = 0;
if (status == RIL_E_SUCCESS) {
GRilIoParser rilp;
int err = -1;
grilio_parser_init(&rilp, data, len);
/* TP-Message-Reference for GSM/
* BearerData MessageId for CDMA
*/
grilio_parser_get_int32(&rilp, &mr);
grilio_parser_skip_string(&rilp);
/* error: 3GPP 27.005, 3.2.5, -1 if unknown or not applicable */
grilio_parser_get_int32(&rilp, &err);
DBG("sms msg ref: %d, error: %d", mr, err);
ril_error_init_ok(&error);
} else if (status == RIL_E_GENERIC_FAILURE) {
ofono_info("not allowed by MO SMS control, do not retry");
error.type = OFONO_ERROR_TYPE_CMS;
error.error = 500;
} else {
ofono_error("sms sending failed, retry");
ril_error_init_failure(&error);
}
cb(&error, mr, cbd->data);
}
static void ril_sms_submit(struct ofono_sms *sms, const unsigned char *pdu,
int pdu_len, int tpdu_len, int mms,
ofono_sms_submit_cb_t cb, void *data)
{
struct ril_sms *sd = ril_sms_get_data(sms);
GRilIoRequest *req = grilio_request_new();
int smsc_len;
char *tpdu;
DBG("pdu_len: %d, tpdu_len: %d mms: %d", pdu_len, tpdu_len, mms);
grilio_request_append_int32(req, 2); /* Number of strings */
/* SMSC address:
*
* smsc_len == 1, then zero-length SMSC was spec'd
* RILD expects a NULL string in this case instead
* of a zero-length string.
*/
smsc_len = pdu_len - tpdu_len;
if (smsc_len > 1) {
/* TODO: encode SMSC & write to parcel */
DBG("SMSC address specified (smsc_len %d); NOT-IMPLEMENTED",
smsc_len);
}
grilio_request_append_utf8(req, NULL); /* default SMSC address */
/* TPDU:
*
* 'pdu' is a raw hexadecimal string
* encode_hex() turns it into an ASCII/hex UTF8 buffer
* grilio_request_append_utf8() encodes utf8 -> utf16
*/
tpdu = encode_hex(pdu + smsc_len, tpdu_len, 0);
grilio_request_append_utf8(req, tpdu);
DBG("%s", tpdu);
grilio_queue_send_request_full(sd->q, req,
mms ? RIL_REQUEST_SEND_SMS_EXPECT_MORE : RIL_REQUEST_SEND_SMS,
ril_sms_submit_cb, ril_sms_cbd_free,
ril_sms_cbd_new(sd, cb, data));
grilio_request_unref(req);
g_free(tpdu);
}
static void ril_ack_delivery_cb(GRilIoChannel *io, int status,
const void *data, guint len, void *user_data)
{
if (status != RIL_E_SUCCESS) {
ofono_error("SMS acknowledgement failed: "
"Further SMS reception is not guaranteed");
}
}
static void ril_ack_delivery(struct ril_sms *sd, gboolean error)
{
GRilIoRequest *req = grilio_request_sized_new(12);
const int code = (error ? 0 : 0xff);
DBG("(%d,%d)", error, code);
grilio_request_append_int32(req, 2); /* Array size*/
grilio_request_append_int32(req, error); /* Success (1)/Failure (0) */
grilio_request_append_int32(req, code); /* error code */
/* ACK the incoming NEW_SMS */
grilio_request_set_retry(req, RIL_SMS_ACK_RETRY_MS,
RIL_SMS_ACK_RETRY_COUNT);
grilio_queue_send_request_full(sd->q, req,
RIL_REQUEST_SMS_ACKNOWLEDGE, ril_ack_delivery_cb, NULL, NULL);
grilio_request_unref(req);
}
static void ril_sms_notify(GRilIoChannel *io, guint ril_event,
const void *data, guint len, void *user_data)
{
struct ril_sms *sd = user_data;
GRilIoParser rilp;
char *ril_pdu;
int ril_pdu_len;
unsigned int smsc_len;
long ril_buf_len;
guchar *ril_data;
ril_pdu = NULL;
ril_data = NULL;
DBG("event: %d; data_len: %d", ril_event, len);
grilio_parser_init(&rilp, data, len);
ril_pdu = grilio_parser_get_utf8(&rilp);
if (ril_pdu == NULL)
goto error;
ril_pdu_len = strlen(ril_pdu);
DBG("ril_pdu_len is %d", ril_pdu_len);
ril_data = decode_hex(ril_pdu, ril_pdu_len, &ril_buf_len, -1);
if (ril_data == NULL)
goto error;
/* The first octect in the pdu contains the SMSC address length
* which is the X following octects it reads. We add 1 octet to
* the read length to take into account this read octet in order
* to calculate the proper tpdu length.
*/
smsc_len = ril_data[0] + 1;
ofono_info("sms received, smsc_len is %d", smsc_len);
DBG("(%s)", ril_pdu);
if (ril_event == RIL_UNSOL_RESPONSE_NEW_SMS) {
/* Last parameter is 'tpdu_len' ( substract SMSC length ) */
ofono_sms_deliver_notify(sd->sms, ril_data, ril_buf_len,
ril_buf_len - smsc_len);
} else {
GASSERT(ril_event == RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT);
ofono_sms_status_notify(sd->sms, ril_data, ril_buf_len,
ril_buf_len - smsc_len);
}
g_free(ril_pdu);
g_free(ril_data);
ril_ack_delivery(sd, TRUE);
return;
error:
g_free(ril_pdu);
g_free(ril_data);
ril_ack_delivery(sd, FALSE);
ofono_error("Unable to parse NEW_SMS notification");
}
static void ril_new_sms_on_sim_cb(GRilIoChannel *io, int status,
const void *data, guint len, void *user_data)
{
DBG("%d", status);
if (status == RIL_E_SUCCESS) {
ofono_info("sms deleted from sim");
} else {
ofono_error("deleting sms from sim failed");
}
}
static void ril_request_delete_sms_om_sim(struct ril_sms *sd, int record)
{
GRilIoRequest *req = grilio_request_sized_new(8);
DBG("Deleting record: %d", record);
grilio_request_append_int32(req, 1); /* Array length */
grilio_request_append_int32(req, record);
grilio_queue_send_request_full(sd->q, req,
RIL_REQUEST_DELETE_SMS_ON_SIM,
ril_new_sms_on_sim_cb, NULL, NULL);
grilio_request_unref(req);
}
static void ril_sms_on_sim_cb(int ok, int total_length, int record,
const unsigned char *sdata, int length, void *userdata)
{
struct ril_sms_on_sim_req *cbd = userdata;
struct ril_sms *sd = cbd->sd;
/*
* It seems when reading EFsms RIL returns the whole record including
* the first status byte therefore we ignore that as we are only
* interested of the following pdu
*/
/* The first octect in the pdu contains the SMSC address length
* which is the X following octects it reads. We add 1 octet to
* the read length to take into account this read octet in order
* to calculate the proper tpdu length.
*/
if (ok) {
unsigned int smsc_len = sdata[1] + 1;
ofono_sms_deliver_notify(sd->sms, sdata + 1, length - 1,
length - smsc_len - 1);
ril_request_delete_sms_om_sim(sd, cbd->record);
} else {
ofono_error("cannot read sms from sim");
}
ril_sms_on_sim_req_free(cbd);
}
static void ril_sms_on_sim(GRilIoChannel *io, guint ril_event,
const void *data, guint len, void *user_data)
{
struct ril_sms *sd = user_data;
struct ofono_sim *sim = ril_modem_ofono_sim(sd->modem);
int data_len = 0, rec = 0;
GRilIoParser rilp;
ofono_info("new sms on sim");
grilio_parser_init(&rilp, data, len);
if (sim &&
grilio_parser_get_int32(&rilp, &data_len) && data_len > 0 &&
grilio_parser_get_int32(&rilp, &rec)) {
DBG("rec %d", rec);
if (sd->sim_context) {
ofono_sim_read_record(sd->sim_context,
SIM_EFSMS_FILEID,
OFONO_SIM_FILE_STRUCTURE_FIXED,
rec, EFSMS_LENGTH,
sim_path, sizeof(sim_path),
ril_sms_on_sim_cb,
ril_sms_on_sim_req_new(sd,rec));
}
}
}
static gboolean ril_sms_register(gpointer user_data)
{
struct ril_sms *sd = user_data;
DBG("");
GASSERT(sd->timer_id);
sd->timer_id = 0;
ofono_sms_register(sd->sms);
/* Register event handlers */
sd->event_id[SMS_EVENT_NEW_SMS] =
grilio_channel_add_unsol_event_handler(sd->io, ril_sms_notify,
RIL_UNSOL_RESPONSE_NEW_SMS, sd);
sd->event_id[SMS_EVENT_NEW_STATUS_REPORT] =
grilio_channel_add_unsol_event_handler(sd->io, ril_sms_notify,
RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT, sd);
sd->event_id[SMS_EVENT_NEW_SMS_ON_SIM] =
grilio_channel_add_unsol_event_handler(sd->io, ril_sms_on_sim,
RIL_UNSOL_RESPONSE_NEW_SMS_ON_SIM, sd);
/* Single-shot */
return FALSE;
}
static int ril_sms_probe(struct ofono_sms *sms, unsigned int vendor,
void *data)
{
struct ril_modem *modem = data;
struct ofono_sim *sim = ril_modem_ofono_sim(modem);
struct ril_sms *sd = g_new0(struct ril_sms, 1);
sd->modem = modem;
sd->sms = sms;
sd->io = grilio_channel_ref(ril_modem_io(modem));
sd->sim_context = ofono_sim_context_create(sim);
sd->q = grilio_queue_new(sd->io);
sd->timer_id = g_idle_add(ril_sms_register, sd);
ofono_sms_set_data(sms, sd);
GASSERT(sd->sim_context);
return 0;
}
static void ril_sms_remove(struct ofono_sms *sms)
{
unsigned int i;
struct ril_sms *sd = ril_sms_get_data(sms);
DBG("");
ofono_sms_set_data(sms, NULL);
if (sd->sim_context) {
ofono_sim_context_free(sd->sim_context);
}
for (i=0; i<G_N_ELEMENTS(sd->event_id); i++) {
grilio_channel_remove_handler(sd->io, sd->event_id[i]);
}
if (sd->timer_id > 0) {
g_source_remove(sd->timer_id);
}
grilio_channel_unref(sd->io);
grilio_queue_cancel_all(sd->q, FALSE);
grilio_queue_unref(sd->q);
g_free(sd);
}
const struct ofono_sms_driver ril_sms_driver = {
.name = RILMODEM_DRIVER,
.probe = ril_sms_probe,
.remove = ril_sms_remove,
.sca_query = ril_sms_sca_query,
.sca_set = ril_sms_sca_set,
.submit = ril_sms_submit,
.bearer_query = NULL, /* FIXME: needs investigation. */
.bearer_set = NULL
};
/*
* Local Variables:
* mode: C
* c-basic-offset: 8
* indent-tabs-mode: t
* End:
*/

302
ofono/drivers/ril/ril_stk.c Normal file
View File

@@ -0,0 +1,302 @@
/*
* oFono - Open Source Telephony - RIL-based devices
*
* Copyright (C) 2015-2017 Jolla Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "ril_plugin.h"
#include "ril_util.h"
#include "ril_log.h"
#include "util.h"
#ifndef UI_LANG
# define UI_LANG "/var/lib/environment/nemo/locale.conf"
#endif
enum ril_stk_events {
STK_EVENT_PROACTIVE_COMMAND,
STK_EVENT_SESSION_END,
STK_EVENT_NOTIFY,
STK_EVENT_COUNT
};
struct ril_stk {
struct ofono_stk *stk;
GRilIoChannel *io;
GRilIoQueue *q;
gulong event_id[STK_EVENT_COUNT];
};
struct ril_stk_cbd {
union _ofono_stk_cb {
ofono_stk_envelope_cb_t envelope;
ofono_stk_generic_cb_t generic;
gpointer ptr;
} cb;
gpointer data;
};
#define ril_stk_cbd_free g_free
static inline struct ril_stk *ril_stk_get_data(struct ofono_stk *stk)
{
return ofono_stk_get_data(stk);
}
struct ril_stk_cbd *ril_stk_cbd_new(void *cb, void *data)
{
struct ril_stk_cbd *cbd = g_new0(struct ril_stk_cbd, 1);
cbd->cb.ptr = cb;
cbd->data = data;
return cbd;
}
static void ril_stk_envelope_cb(GRilIoChannel *io, int status,
const void *data, guint len, void *user_data)
{
struct ofono_error error;
struct ril_stk_cbd *cbd = user_data;
ofono_stk_envelope_cb_t cb = cbd->cb.envelope;
if (status == RIL_E_SUCCESS) {
DBG("%u bytes(s)", len);
cb(ril_error_ok(&error), NULL, 0, cbd->data);
} else {
DBG("Envelope reply failure: %s", ril_error_to_string(status));
cb(ril_error_failure(&error), NULL, 0, cbd->data);
}
}
static void ril_stk_envelope(struct ofono_stk *stk, int length,
const unsigned char *cmd, ofono_stk_envelope_cb_t cb, void *data)
{
struct ril_stk *sd = ril_stk_get_data(stk);
GRilIoRequest *req = grilio_request_new();
char *hex_envelope = encode_hex(cmd, length, 0);
DBG("%s", hex_envelope);
grilio_request_append_utf8(req, hex_envelope);
g_free(hex_envelope);
grilio_queue_send_request_full(sd->q, req,
RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND,
ril_stk_envelope_cb, ril_stk_cbd_free,
ril_stk_cbd_new(cb, data));
grilio_request_unref(req);
}
static void ril_stk_terminal_response_cb(GRilIoChannel *io, int status,
const void *data, guint len, void *user_data)
{
struct ofono_error error;
struct ril_stk_cbd *cbd = user_data;
ofono_stk_generic_cb_t cb = cbd->cb.generic;
DBG("");
if (status == RIL_E_SUCCESS) {
cb(ril_error_ok(&error), cbd->data);
} else {
ofono_error("Error in sending terminal response");
cb(ril_error_failure(&error), cbd->data);
}
}
static void ril_stk_terminal_response(struct ofono_stk *stk, int length,
const unsigned char *resp,
ofono_stk_generic_cb_t cb, void *data)
{
struct ril_stk *sd = ril_stk_get_data(stk);
GRilIoRequest *req = grilio_request_new();
char *hex_tr = encode_hex(resp, length, 0);
DBG("rilmodem terminal response: %s", hex_tr);
grilio_request_append_utf8(req, hex_tr);
g_free(hex_tr);
grilio_queue_send_request_full(sd->q, req,
RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE,
ril_stk_terminal_response_cb,
ril_stk_cbd_free, ril_stk_cbd_new(cb, data));
grilio_request_unref(req);
}
static void ril_stk_user_confirmation(struct ofono_stk *stk,
ofono_bool_t confirm)
{
struct ril_stk *sd = ril_stk_get_data(stk);
GRilIoRequest *req = grilio_request_sized_new(8);
DBG("%d", confirm);
grilio_request_append_int32(req, 1); /* size of array */
grilio_request_append_int32(req, confirm); /* yes/no */
grilio_queue_send_request(sd->q, req,
RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM);
grilio_request_unref(req);
}
static void ril_stk_pcmd_notify(GRilIoChannel *io, guint code,
const void *data, guint data_len, void *user_data)
{
struct ril_stk *sd = user_data;
GRilIoParser rilp;
char *pcmd;
guchar *pdu;
long len = 0;
GASSERT(code == RIL_UNSOL_STK_PROACTIVE_COMMAND);
grilio_parser_init(&rilp, data, data_len);
pcmd = grilio_parser_get_utf8(&rilp);
DBG("pcmd: %s", pcmd);
pdu = decode_hex(pcmd, strlen(pcmd), &len, -1);
g_free(pcmd);
ofono_stk_proactive_command_notify(sd->stk, len, pdu);
g_free(pdu);
}
static void ril_stk_event_notify(GRilIoChannel *io, guint code,
const void *data, guint data_len, void *user_data)
{
struct ril_stk *sd = user_data;
GRilIoParser rilp;
char *pcmd = NULL;
guchar *pdu = NULL;
long len;
/* Proactive command has been handled by the modem. */
GASSERT(code == RIL_UNSOL_STK_EVENT_NOTIFY);
grilio_parser_init(&rilp, data, data_len);
pcmd = grilio_parser_get_utf8(&rilp);
DBG("pcmd: %s", pcmd);
pdu = decode_hex(pcmd, strlen(pcmd), &len, -1);
g_free(pcmd);
ofono_stk_proactive_command_handled_notify(sd->stk, len, pdu);
g_free(pdu);
}
static void ril_stk_session_end_notify(GRilIoChannel *io, guint code,
const void *data, guint len, void *user_data)
{
struct ril_stk *sd = user_data;
DBG("");
GASSERT(code == RIL_UNSOL_STK_SESSION_END);
ofono_stk_proactive_session_end_notify(sd->stk);
}
static void ril_stk_agent_ready(struct ofono_stk *stk)
{
struct ril_stk *sd = ril_stk_get_data(stk);
DBG("");
if (!sd->event_id[STK_EVENT_PROACTIVE_COMMAND]) {
DBG("Subscribing notifications");
sd->event_id[STK_EVENT_PROACTIVE_COMMAND] =
grilio_channel_add_unsol_event_handler(sd->io,
ril_stk_pcmd_notify,
RIL_UNSOL_STK_PROACTIVE_COMMAND, sd);
GASSERT(!sd->event_id[STK_EVENT_SESSION_END]);
sd->event_id[STK_EVENT_SESSION_END] =
grilio_channel_add_unsol_event_handler(sd->io,
ril_stk_session_end_notify,
RIL_UNSOL_STK_SESSION_END, sd);
GASSERT(!sd->event_id[STK_EVENT_NOTIFY]);
sd->event_id[STK_EVENT_NOTIFY] =
grilio_channel_add_unsol_event_handler(sd->io,
ril_stk_event_notify,
RIL_UNSOL_STK_EVENT_NOTIFY, sd);
grilio_queue_send_request(sd->q, NULL,
RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING);
}
}
static void ril_stk_set_lang()
{
GError *error = NULL;
GIOChannel* chan = g_io_channel_new_file(UI_LANG, "r", &error);
if (chan) {
GString* buf = g_string_new(NULL);
gsize term;
while (g_io_channel_read_line_string(chan, buf, &term, NULL) ==
G_IO_STATUS_NORMAL) {
char* lang;
g_string_set_size(buf, term);
lang = strstr(buf->str, "LANG=");
if (lang) {
setenv("LANG", lang + 5, TRUE);
}
}
g_string_free(buf, TRUE);
g_io_channel_unref(chan);
} else {
DBG("%s: %s", UI_LANG, error->message);
g_error_free(error);
}
}
static int ril_stk_probe(struct ofono_stk *stk, unsigned int vendor, void *data)
{
struct ril_modem *modem = data;
struct ril_stk *sd = g_new0(struct ril_stk, 1);
DBG("");
sd->stk = stk;
sd->io = grilio_channel_ref(ril_modem_io(modem));
sd->q = grilio_queue_new(sd->io);
ofono_stk_set_data(stk, sd);
ofono_stk_register(stk);
ril_stk_set_lang();
return 0;
}
static void ril_stk_remove(struct ofono_stk *stk)
{
struct ril_stk *sd = ril_stk_get_data(stk);
unsigned int i;
DBG("");
ofono_stk_set_data(stk, NULL);
for (i=0; i<G_N_ELEMENTS(sd->event_id); i++) {
grilio_channel_remove_handler(sd->io, sd->event_id[i]);
}
grilio_channel_unref(sd->io);
grilio_queue_cancel_all(sd->q, FALSE);
grilio_queue_unref(sd->q);
g_free(sd);
}
const struct ofono_stk_driver ril_stk_driver = {
.name = RILMODEM_DRIVER,
.probe = ril_stk_probe,
.remove = ril_stk_remove,
.envelope = ril_stk_envelope,
.terminal_response = ril_stk_terminal_response,
.user_confirmation = ril_stk_user_confirmation,
.ready = ril_stk_agent_ready
};
/*
* Local Variables:
* mode: C
* c-basic-offset: 8
* indent-tabs-mode: t
* End:
*/

View File

@@ -0,0 +1,204 @@
# This is a sample configuration file for Jolla ril driver
#
# This file is expected to be installed in /etc/ofono
#
# Configuration for each modem is defined in its own [ril_x] section,
# common settings are in the [Settings] section, all other sections
# are ignored.
#
# If any value from [ril_x] section (except "socket") is defined
# in the [Settings] section, it becomes the default for all modems.
# Default values can still be redefined at [ril_x] level.
#
[Settings]
# This option stops RIL plugin from creating any RIL modems.
# If it's set to true, all [ril_x] sections are ignored even
# if they are present, and no default configurtation is created.
#
# Default is false
#
#EmptyConfig=false
# User and group for the ofono process. RIL clients are typically
# expected to run under radio:radio.
#
# Default is radio:radio
#
#Identity=radio:radio
# If the phone has more than one SIM slot, the 3G/LTE module may be
# shared by all modems, meaning that only one of the slots can use
# 3G/LTE. In order to "hand 4G over" to the other slot, the modem
# currently using 3G/LTE has to drop to GSM, release 3G/LTE module
# and only then 3G/LTE can be used by the other modem. This setting
# allows to disable this behaviour (say, if your phone has independent
# 3G/LTE modules for each slot or you don't need 4G for both slots).
# Obviously, it only has any effect if you have more than one SIM.
#
# Default is true (switch the current data modem to 2G when changing
# the data modems)
#
#3GLTEHandover=true
# RIL_REQUEST_SET_RADIO_CAPABILITY may or may not be supported by your RIL.
# This option allows you to forcibly enable or disable use of this request.
# It's involved in 3G/LTE handover between the modems, meaning that it only
# makes sense if you have more than one slot.
#
# Possible values are auto, on and off
#
# Default is auto (enable for RIL version >= 11)
#
#SetRadioCapability=auto
[ril_0]
# Required entry, defines the RIL socket path
socket=/dev/socket/rild
# Subscription string. Some (mostly, older) RILs require that 4 bytes
# (usually SUB1 or SUB2) are written to the socket before rild starts
# talking to us.
#
# Not sent by default.
#
#sub=SUB1
# RIL logging prefix, to tell one socket from another in the log.
# Makes sense if you have more than one modem configured.
#
# No prefix by default.
#
#name=RIL1
# Slot id for SET_UICC_SUBSCRIPTION request.
#
# By default the first modem becomes slot 0, the next one slot 1 and so on.
#
#slot=0
# RIL request timeout, in milliseconds.
#
# The default is zero (no timeout)
#
#timeout=0
# Comma-separated list of radio technologies supported by the modem.
# Valid technologies are "gsm", "umts" and "lte". The special value
# "all" means that all technologies are supported.
#
# The default is all
#
#technologies=all
# This one is deprecated, use the technologies entry instead (above).
#
#enable4G=true
# RIL_REQUEST_SET_UICC_SUBSCRIPTION is 115 in RIL version 9 (or earlier)
# and 122 in RIL version 10 and later. Since ofono doesn't know in advance
# which RIL version it's dealing with, it makes the decision at runtime.
# Settings it to false disables the workaround and always sends 122.
#
# Default is true (select SET_UICC_SUBSCRIPTION based on the RIL version)
#
#uiccWorkaround=true
# Points to the file containing comma-separated ECC (Emergency List Codes)
# list, e.g. 911,112,*911,#911. The file is tracked by ofono and when its
# contents changes, it's reflected in the EmergencyNumbers property of
# org.ofono.VoiceCallManager.
#
# If necessary, the contents of the file can be synchronized with the
# Android system property by adding something like this to /init.rc:
#
# on property:ril.ecclist=*
# write /var/lib/ofono/ril.ecclist ${ril.ecclist}
# chmod 0644 /var/lib/ofono/ril.ecclist
#
#ecclistFile=/var/lib/ofono/ril.ecclist
# RIL_REQUEST_ALLOW_DATA may or may not be supported by your RIL.
# This option allows you to forcibly enable or disable use of this request.
# Possible values are auto, on and off
#
# Default is auto (enable for RIL version >= 11)
#
#allowDataReq=auto
# Since RIL interface doesn't provide the standard way of querying the
# number of pin retries left, some RIL implementation (namely Qualcomm)
# allow to query the retry count by sending the empty pin. If your RIL
# actually does check the empty pin (and decrements the retry count)
# then you should turn this feature off.
#
# Default is true
#
#emptyPinQuery=true
# Different RILs use different data call structures which don't necessarily
# match the format specified in the data list header. The header may have
# version 9 but the list may contain RIL_Data_Call_Response_v6 structures,
# list version 10 may contain RIL_Data_Call_Response_v11 and so on. By default
# ofono assumes that the version from the list header matches the contents
# but sometimes you have to explicitly tell ofono which one to use.
# Possible values are 6, 9, 11 and auto.
#
# Default is auto
#
#dataCallFormat=auto
# Data call may fail with status 65535 which according to ril.h means that
# we need to retry silently. The maximum number of retries is limited by
# this parameter. Usually, one retry is enough. The first retry occurs
# immediately, the subsequent ones after dataCallRetryDelay (see below)
#
# Default is 4
#
#dataCallRetryLimit=4
# Delay between data call retries, in milliseconds. Note that the first
# retry occurs immediately after the first failure, the delays are only
# applied if the first retry fails too.
#
# Default is 200 ms
#
#dataCallRetryDelay=200
# Additional local and remote hangup reasons. Remote reasons are checked
# first. Normally, RIL plugin figures it out automatically. You would only
# need to define these if your RIL does something unusual.
#
# No default
#
#remoteHangupReasons=20
#localHangupReasons=23
# Voice call support. Some devices like USB modems and tablets don't support
# voice calls. By default, voice calls are enabled and this option allows you
# to disable voice call handling.
#
# Default true
#
#enableVoicecall=true
# Timeout for the modem to show up, in milliseconds. Those that don't
# show up before this timeout expires, will be dropped (ignored).
#
# In some fairly rare cases it makes sense to shorten this timeout for
# optional modems (which may or may not be available), to speed up the
# boot up process.
#
# The default is 20000 (20 seconds)
#
#startTimeout=20000
# This allows to use deprecated RIL_REQUEST_GET_IMEI instead of
# RIL_REQUEST_DEVICE_IDENTITY to query IMEI from the modem. Some
# RILs (e.g. MTK) still don't understand RIL_REQUEST_DEVICE_IDENTITY.
#
# Default is false (use RIL_REQUEST_DEVICE_IDENTITY)
#
#legacyImeiQuery=false

View File

@@ -0,0 +1,68 @@
/*
* oFono - Open Source Telephony - RIL-based devices
*
* Copyright (C) 2015-2017 Jolla Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#ifndef RIL_TYPES_H
#define RIL_TYPES_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <grilio_types.h>
#include <gutil_macros.h>
struct ofono_modem;
struct ofono_sim;
#include <ofono/types.h>
#include <ofono/radio-settings.h>
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "ril_constants.h"
#define RIL_RETRY_SECS (2)
#define RIL_RETRY_MS (RIL_RETRY_SECS*1000)
struct ril_data;
struct ril_data_call;
struct ril_modem;
struct ril_radio;
struct ril_network;
struct ril_sim_card;
struct ril_vendor_hook;
struct ril_slot_config {
guint slot;
enum ofono_radio_access_mode techs;
gboolean empty_pin_query;
gboolean enable_voicecall;
GUtilInts *local_hangup_reasons;
GUtilInts *remote_hangup_reasons;
};
#endif /* RIL_TYPES_H */
/*
* Local Variables:
* mode: C
* c-basic-offset: 8
* indent-tabs-mode: t
* End:
*/

View File

@@ -0,0 +1,221 @@
/*
* oFono - Open Source Telephony - RIL-based devices
*
* Copyright (C) 2015-2017 Jolla Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "ril_plugin.h"
#include "ril_util.h"
#include "ril_log.h"
#include "smsutil.h"
#include "util.h"
struct ril_ussd {
struct ofono_ussd *ussd;
GRilIoChannel *io;
GRilIoQueue *q;
guint timer_id;
gulong event_id;
};
struct ril_ussd_cbd {
ofono_ussd_cb_t cb;
gpointer data;
};
#define ril_ussd_cbd_free g_free
static inline struct ril_ussd *ril_ussd_get_data(struct ofono_ussd *ussd)
{
return ofono_ussd_get_data(ussd);
}
static struct ril_ussd_cbd *ril_ussd_cbd_new(ofono_ussd_cb_t cb, void *data)
{
struct ril_ussd_cbd *cbd = g_new0(struct ril_ussd_cbd, 1);
cbd->cb = cb;
cbd->data = data;
return cbd;
}
static void ril_ussd_cancel_cb(GRilIoChannel *io, int status,
const void *data, guint len, void *user_data)
{
struct ofono_error error;
struct ril_ussd_cbd *cbd = user_data;
/* Always report sucessful completion, otherwise ofono may get
* stuck in the USSD_STATE_ACTIVE state */
cbd->cb(ril_error_ok(&error), cbd->data);
}
static void ril_ussd_request(struct ofono_ussd *ussd, int dcs,
const unsigned char *pdu, int len, ofono_ussd_cb_t cb, void *data)
{
struct ofono_error error;
enum sms_charset charset;
struct ril_ussd *ud = ril_ussd_get_data(ussd);
ofono_info("send ussd, len:%d", len);
if (cbs_dcs_decode(dcs, NULL, NULL, &charset, NULL, NULL, NULL)) {
if (charset == SMS_CHARSET_7BIT) {
unsigned char unpacked_buf[182];
long written = 0;
unpack_7bit_own_buf(pdu, len, 0, TRUE,
sizeof(unpacked_buf)-1, &written, 0,
unpacked_buf);
unpacked_buf[written] = 0;
if (written >= 1) {
/*
* When USSD was packed, additional CR
* might have been added (according to
* 23.038 6.1.2.3.1). So if the last
* character is CR, it should be removed
* here.
*
* Over 2 characters long USSD string must
* end with # (checked in valid_ussd_string),
* so it should be safe to remove extra CR.
*/
GRilIoRequest *req = grilio_request_new();
int length = strlen((char *)unpacked_buf);
while (length > 2 &&
unpacked_buf[length-1] == '\r') {
unpacked_buf[--length] = 0;
}
grilio_request_append_utf8_chars(req, (char*)
unpacked_buf, length);
grilio_queue_send_request(ud->q, req,
RIL_REQUEST_SEND_USSD);
grilio_request_unref(req);
cb(ril_error_ok(&error), data);
return;
}
}
}
cb(ril_error_failure(&error), data);
}
static void ril_ussd_cancel(struct ofono_ussd *ussd,
ofono_ussd_cb_t cb, void *data)
{
struct ril_ussd *ud = ril_ussd_get_data(ussd);
ofono_info("send ussd cancel");
grilio_queue_send_request_full(ud->q, NULL, RIL_REQUEST_CANCEL_USSD,
ril_ussd_cancel_cb, ril_ussd_cbd_free,
ril_ussd_cbd_new(cb, data));
}
static void ril_ussd_notify(GRilIoChannel *io, guint code,
const void *data, guint len, void *user_data)
{
struct ril_ussd *ud = user_data;
GRilIoParser rilp;
char *type;
guint32 n = 0;
ofono_info("ussd received");
GASSERT(code == RIL_UNSOL_ON_USSD);
grilio_parser_init(&rilp, data, len);
grilio_parser_get_uint32(&rilp, &n);
type = grilio_parser_get_utf8(&rilp);
if (type) {
int ussdtype = g_ascii_xdigit_value(*type);
char *msg = (n > 1) ? grilio_parser_get_utf8(&rilp) : NULL;
if (msg) {
const int msglen = strlen(msg);
DBG("ussd length %d", msglen);
ofono_ussd_notify(ud->ussd, ussdtype, 0xFF,
(const unsigned char *)msg, msglen);
/* msg is freed by core if dcs is 0xFF */
} else {
ofono_ussd_notify(ud->ussd, ussdtype, 0, NULL, 0);
}
g_free(type);
}
}
static gboolean ril_ussd_register(gpointer user_data)
{
struct ril_ussd *ud = user_data;
DBG("");
GASSERT(ud->timer_id);
ud->timer_id = 0;
ofono_ussd_register(ud->ussd);
/* Register for USSD events */
ud->event_id = grilio_channel_add_unsol_event_handler(ud->io,
ril_ussd_notify, RIL_UNSOL_ON_USSD, ud);
/* Single-shot */
return G_SOURCE_REMOVE;
}
static int ril_ussd_probe(struct ofono_ussd *ussd, unsigned int vendor,
void *data)
{
struct ril_modem *modem = data;
struct ril_ussd *ud = g_try_new0(struct ril_ussd, 1);
DBG("");
ud->ussd = ussd;
ud->io = grilio_channel_ref(ril_modem_io(modem));
ud->q = grilio_queue_new(ud->io);
ud->timer_id = g_idle_add(ril_ussd_register, ud);
ofono_ussd_set_data(ussd, ud);
return 0;
}
static void ril_ussd_remove(struct ofono_ussd *ussd)
{
struct ril_ussd *ud = ril_ussd_get_data(ussd);
DBG("");
ofono_ussd_set_data(ussd, NULL);
if (ud->timer_id > 0) {
g_source_remove(ud->timer_id);
}
grilio_channel_remove_handler(ud->io, ud->event_id);
grilio_channel_unref(ud->io);
grilio_queue_cancel_all(ud->q, FALSE);
grilio_queue_unref(ud->q);
g_free(ud);
}
const struct ofono_ussd_driver ril_ussd_driver = {
.name = RILMODEM_DRIVER,
.probe = ril_ussd_probe,
.remove = ril_ussd_remove,
.request = ril_ussd_request,
.cancel = ril_ussd_cancel
};
/*
* Local Variables:
* mode: C
* c-basic-offset: 8
* indent-tabs-mode: t
* End:
*/

View File

@@ -0,0 +1,440 @@
/*
* oFono - Open Source Telephony - RIL-based devices
*
* Copyright (C) 2015-2017 Jolla Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "ril_util.h"
#include "ril_log.h"
#include <grilio_channel.h>
#include <sys/socket.h>
#include <ctype.h>
#include <errno.h>
#include <limits.h>
#include "common.h"
#include "netreg.h"
const char *ril_error_to_string(int error)
{
#define RIL_E_(name) case RIL_E_##name: return #name
#define GRILIO_E_(name) case GRILIO_STATUS_##name: return "GRILIO_" #name
static char unknown[12];
switch (error) {
case RIL_E_SUCCESS: return "OK";
GRILIO_E_(TIMEOUT);
GRILIO_E_(CANCELLED);
RIL_E_(RADIO_NOT_AVAILABLE);
RIL_E_(GENERIC_FAILURE);
RIL_E_(PASSWORD_INCORRECT);
RIL_E_(SIM_PIN2);
RIL_E_(SIM_PUK2);
RIL_E_(REQUEST_NOT_SUPPORTED);
RIL_E_(CANCELLED);
RIL_E_(OP_NOT_ALLOWED_DURING_VOICE_CALL);
RIL_E_(OP_NOT_ALLOWED_BEFORE_REG_TO_NW);
RIL_E_(SMS_SEND_FAIL_RETRY);
RIL_E_(SIM_ABSENT);
RIL_E_(SUBSCRIPTION_NOT_AVAILABLE);
RIL_E_(MODE_NOT_SUPPORTED);
RIL_E_(FDN_CHECK_FAILURE);
RIL_E_(ILLEGAL_SIM_OR_ME);
RIL_E_(MISSING_RESOURCE);
RIL_E_(NO_SUCH_ELEMENT);
RIL_E_(DIAL_MODIFIED_TO_USSD);
RIL_E_(DIAL_MODIFIED_TO_SS);
RIL_E_(DIAL_MODIFIED_TO_DIAL);
RIL_E_(USSD_MODIFIED_TO_DIAL);
RIL_E_(USSD_MODIFIED_TO_SS);
RIL_E_(USSD_MODIFIED_TO_USSD);
RIL_E_(SS_MODIFIED_TO_DIAL);
RIL_E_(SS_MODIFIED_TO_USSD);
RIL_E_(SUBSCRIPTION_NOT_SUPPORTED);
RIL_E_(SS_MODIFIED_TO_SS);
RIL_E_(LCE_NOT_SUPPORTED);
RIL_E_(NO_MEMORY);
RIL_E_(INTERNAL_ERR);
RIL_E_(SYSTEM_ERR);
RIL_E_(MODEM_ERR);
RIL_E_(INVALID_STATE);
RIL_E_(NO_RESOURCES);
RIL_E_(SIM_ERR);
RIL_E_(INVALID_ARGUMENTS);
RIL_E_(INVALID_SIM_STATE);
RIL_E_(INVALID_MODEM_STATE);
RIL_E_(INVALID_CALL_ID);
RIL_E_(NO_SMS_TO_ACK);
RIL_E_(NETWORK_ERR);
RIL_E_(REQUEST_RATE_LIMITED);
RIL_E_(SIM_BUSY);
RIL_E_(SIM_FULL);
RIL_E_(NETWORK_REJECT);
RIL_E_(OPERATION_NOT_ALLOWED);
RIL_E_(EMPTY_RECORD);
RIL_E_(INVALID_SMS_FORMAT);
RIL_E_(ENCODING_ERR);
RIL_E_(INVALID_SMSC_ADDRESS);
RIL_E_(NO_SUCH_ENTRY);
RIL_E_(NETWORK_NOT_READY);
RIL_E_(NOT_PROVISIONED);
RIL_E_(NO_SUBSCRIPTION);
RIL_E_(NO_NETWORK_FOUND);
RIL_E_(DEVICE_IN_USE);
RIL_E_(ABORTED);
RIL_E_(INVALID_RESPONSE);
default:
snprintf(unknown, sizeof(unknown), "%d", error);
return unknown;
}
}
const char *ril_request_to_string(guint request)
{
#define RIL_REQUEST_(name) case RIL_REQUEST_##name: return #name
static char unknown[24];
switch (request) {
RIL_REQUEST_(GET_SIM_STATUS);
RIL_REQUEST_(ENTER_SIM_PIN);
RIL_REQUEST_(ENTER_SIM_PUK);
RIL_REQUEST_(ENTER_SIM_PIN2);
RIL_REQUEST_(ENTER_SIM_PUK2);
RIL_REQUEST_(CHANGE_SIM_PIN);
RIL_REQUEST_(CHANGE_SIM_PIN2);
RIL_REQUEST_(ENTER_NETWORK_DEPERSONALIZATION);
RIL_REQUEST_(GET_CURRENT_CALLS);
RIL_REQUEST_(DIAL);
RIL_REQUEST_(GET_IMSI);
RIL_REQUEST_(HANGUP);
RIL_REQUEST_(HANGUP_WAITING_OR_BACKGROUND);
RIL_REQUEST_(HANGUP_FOREGROUND_RESUME_BACKGROUND);
RIL_REQUEST_(SWITCH_HOLDING_AND_ACTIVE);
RIL_REQUEST_(CONFERENCE);
RIL_REQUEST_(UDUB);
RIL_REQUEST_(LAST_CALL_FAIL_CAUSE);
RIL_REQUEST_(SIGNAL_STRENGTH);
RIL_REQUEST_(VOICE_REGISTRATION_STATE);
RIL_REQUEST_(DATA_REGISTRATION_STATE);
RIL_REQUEST_(OPERATOR);
RIL_REQUEST_(RADIO_POWER);
RIL_REQUEST_(DTMF);
RIL_REQUEST_(SEND_SMS);
RIL_REQUEST_(SEND_SMS_EXPECT_MORE);
RIL_REQUEST_(SETUP_DATA_CALL);
RIL_REQUEST_(SIM_IO);
RIL_REQUEST_(SEND_USSD);
RIL_REQUEST_(CANCEL_USSD);
RIL_REQUEST_(GET_CLIR);
RIL_REQUEST_(SET_CLIR);
RIL_REQUEST_(QUERY_CALL_FORWARD_STATUS);
RIL_REQUEST_(SET_CALL_FORWARD);
RIL_REQUEST_(QUERY_CALL_WAITING);
RIL_REQUEST_(SET_CALL_WAITING);
RIL_REQUEST_(SMS_ACKNOWLEDGE);
RIL_REQUEST_(GET_IMEI);
RIL_REQUEST_(GET_IMEISV);
RIL_REQUEST_(ANSWER);
RIL_REQUEST_(DEACTIVATE_DATA_CALL);
RIL_REQUEST_(QUERY_FACILITY_LOCK);
RIL_REQUEST_(SET_FACILITY_LOCK);
RIL_REQUEST_(CHANGE_BARRING_PASSWORD);
RIL_REQUEST_(QUERY_NETWORK_SELECTION_MODE);
RIL_REQUEST_(SET_NETWORK_SELECTION_AUTOMATIC);
RIL_REQUEST_(SET_NETWORK_SELECTION_MANUAL);
RIL_REQUEST_(QUERY_AVAILABLE_NETWORKS);
RIL_REQUEST_(DTMF_START);
RIL_REQUEST_(DTMF_STOP);
RIL_REQUEST_(BASEBAND_VERSION);
RIL_REQUEST_(SEPARATE_CONNECTION);
RIL_REQUEST_(SET_MUTE);
RIL_REQUEST_(GET_MUTE);
RIL_REQUEST_(QUERY_CLIP);
RIL_REQUEST_(LAST_DATA_CALL_FAIL_CAUSE);
RIL_REQUEST_(DATA_CALL_LIST);
RIL_REQUEST_(RESET_RADIO);
RIL_REQUEST_(OEM_HOOK_RAW);
RIL_REQUEST_(OEM_HOOK_STRINGS);
RIL_REQUEST_(SCREEN_STATE);
RIL_REQUEST_(SET_SUPP_SVC_NOTIFICATION);
RIL_REQUEST_(WRITE_SMS_TO_SIM);
RIL_REQUEST_(DELETE_SMS_ON_SIM);
RIL_REQUEST_(SET_BAND_MODE);
RIL_REQUEST_(QUERY_AVAILABLE_BAND_MODE);
RIL_REQUEST_(STK_GET_PROFILE);
RIL_REQUEST_(STK_SET_PROFILE);
RIL_REQUEST_(STK_SEND_ENVELOPE_COMMAND);
RIL_REQUEST_(STK_SEND_TERMINAL_RESPONSE);
RIL_REQUEST_(STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM);
RIL_REQUEST_(EXPLICIT_CALL_TRANSFER);
RIL_REQUEST_(SET_PREFERRED_NETWORK_TYPE);
RIL_REQUEST_(GET_PREFERRED_NETWORK_TYPE);
RIL_REQUEST_(GET_NEIGHBORING_CELL_IDS);
RIL_REQUEST_(SET_LOCATION_UPDATES);
RIL_REQUEST_(CDMA_SET_SUBSCRIPTION_SOURCE);
RIL_REQUEST_(CDMA_SET_ROAMING_PREFERENCE);
RIL_REQUEST_(CDMA_QUERY_ROAMING_PREFERENCE);
RIL_REQUEST_(SET_TTY_MODE);
RIL_REQUEST_(QUERY_TTY_MODE);
RIL_REQUEST_(CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE);
RIL_REQUEST_(CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE);
RIL_REQUEST_(CDMA_FLASH);
RIL_REQUEST_(CDMA_BURST_DTMF);
RIL_REQUEST_(CDMA_VALIDATE_AND_WRITE_AKEY);
RIL_REQUEST_(CDMA_SEND_SMS);
RIL_REQUEST_(CDMA_SMS_ACKNOWLEDGE);
RIL_REQUEST_(GSM_GET_BROADCAST_SMS_CONFIG);
RIL_REQUEST_(GSM_SET_BROADCAST_SMS_CONFIG);
RIL_REQUEST_(GSM_SMS_BROADCAST_ACTIVATION);
RIL_REQUEST_(CDMA_GET_BROADCAST_SMS_CONFIG);
RIL_REQUEST_(CDMA_SET_BROADCAST_SMS_CONFIG);
RIL_REQUEST_(CDMA_SMS_BROADCAST_ACTIVATION);
RIL_REQUEST_(CDMA_SUBSCRIPTION);
RIL_REQUEST_(CDMA_WRITE_SMS_TO_RUIM);
RIL_REQUEST_(CDMA_DELETE_SMS_ON_RUIM);
RIL_REQUEST_(DEVICE_IDENTITY);
RIL_REQUEST_(EXIT_EMERGENCY_CALLBACK_MODE);
RIL_REQUEST_(GET_SMSC_ADDRESS);
RIL_REQUEST_(SET_SMSC_ADDRESS);
RIL_REQUEST_(REPORT_SMS_MEMORY_STATUS);
RIL_REQUEST_(REPORT_STK_SERVICE_IS_RUNNING);
RIL_REQUEST_(CDMA_GET_SUBSCRIPTION_SOURCE);
RIL_REQUEST_(ISIM_AUTHENTICATION);
RIL_REQUEST_(ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU);
RIL_REQUEST_(STK_SEND_ENVELOPE_WITH_STATUS);
RIL_REQUEST_(VOICE_RADIO_TECH);
RIL_REQUEST_(GET_CELL_INFO_LIST);
RIL_REQUEST_(SET_UNSOL_CELL_INFO_LIST_RATE);
RIL_REQUEST_(SET_INITIAL_ATTACH_APN);
RIL_REQUEST_(IMS_REGISTRATION_STATE);
RIL_REQUEST_(IMS_SEND_SMS);
RIL_REQUEST_(SIM_TRANSMIT_APDU_BASIC);
RIL_REQUEST_(SIM_OPEN_CHANNEL);
RIL_REQUEST_(SIM_CLOSE_CHANNEL);
RIL_REQUEST_(SIM_TRANSMIT_APDU_CHANNEL);
RIL_REQUEST_(NV_READ_ITEM);
RIL_REQUEST_(NV_WRITE_ITEM);
RIL_REQUEST_(NV_WRITE_CDMA_PRL);
RIL_REQUEST_(NV_RESET_CONFIG);
RIL_REQUEST_(SET_UICC_SUBSCRIPTION);
RIL_REQUEST_(ALLOW_DATA);
RIL_REQUEST_(GET_HARDWARE_CONFIG);
RIL_REQUEST_(SIM_AUTHENTICATION);
RIL_REQUEST_(GET_DC_RT_INFO);
RIL_REQUEST_(SET_DC_RT_INFO_RATE);
RIL_REQUEST_(SET_DATA_PROFILE);
RIL_REQUEST_(SHUTDOWN);
RIL_REQUEST_(GET_RADIO_CAPABILITY);
RIL_REQUEST_(SET_RADIO_CAPABILITY);
case RIL_RESPONSE_ACKNOWLEDGEMENT:
return "RESPONSE_ACK";
default:
snprintf(unknown, sizeof(unknown), "RIL_REQUEST_%d", request);
return unknown;
}
}
const char *ril_unsol_event_to_string(guint event)
{
#define RIL_UNSOL_(name) case RIL_UNSOL_##name: return #name
static char unknown[24];
switch (event) {
RIL_UNSOL_(RESPONSE_RADIO_STATE_CHANGED);
RIL_UNSOL_(RESPONSE_CALL_STATE_CHANGED);
RIL_UNSOL_(RESPONSE_VOICE_NETWORK_STATE_CHANGED);
RIL_UNSOL_(RESPONSE_NEW_SMS);
RIL_UNSOL_(RESPONSE_NEW_SMS_STATUS_REPORT);
RIL_UNSOL_(RESPONSE_NEW_SMS_ON_SIM);
RIL_UNSOL_(ON_USSD);
RIL_UNSOL_(ON_USSD_REQUEST);
RIL_UNSOL_(NITZ_TIME_RECEIVED);
RIL_UNSOL_(SIGNAL_STRENGTH);
RIL_UNSOL_(DATA_CALL_LIST_CHANGED);
RIL_UNSOL_(SUPP_SVC_NOTIFICATION);
RIL_UNSOL_(STK_SESSION_END);
RIL_UNSOL_(STK_PROACTIVE_COMMAND);
RIL_UNSOL_(STK_EVENT_NOTIFY);
RIL_UNSOL_(STK_CALL_SETUP);
RIL_UNSOL_(SIM_SMS_STORAGE_FULL);
RIL_UNSOL_(SIM_REFRESH);
RIL_UNSOL_(CALL_RING);
RIL_UNSOL_(RESPONSE_SIM_STATUS_CHANGED);
RIL_UNSOL_(RESPONSE_CDMA_NEW_SMS);
RIL_UNSOL_(RESPONSE_NEW_BROADCAST_SMS);
RIL_UNSOL_(CDMA_RUIM_SMS_STORAGE_FULL);
RIL_UNSOL_(RESTRICTED_STATE_CHANGED);
RIL_UNSOL_(ENTER_EMERGENCY_CALLBACK_MODE);
RIL_UNSOL_(CDMA_CALL_WAITING);
RIL_UNSOL_(CDMA_OTA_PROVISION_STATUS);
RIL_UNSOL_(CDMA_INFO_REC);
RIL_UNSOL_(OEM_HOOK_RAW);
RIL_UNSOL_(RINGBACK_TONE);
RIL_UNSOL_(RESEND_INCALL_MUTE);
RIL_UNSOL_(CDMA_SUBSCRIPTION_SOURCE_CHANGED);
RIL_UNSOL_(CDMA_PRL_CHANGED);
RIL_UNSOL_(EXIT_EMERGENCY_CALLBACK_MODE);
RIL_UNSOL_(RIL_CONNECTED);
RIL_UNSOL_(VOICE_RADIO_TECH_CHANGED);
RIL_UNSOL_(CELL_INFO_LIST);
RIL_UNSOL_(RESPONSE_IMS_NETWORK_STATE_CHANGED);
RIL_UNSOL_(UICC_SUBSCRIPTION_STATUS_CHANGED);
RIL_UNSOL_(SRVCC_STATE_NOTIFY);
RIL_UNSOL_(HARDWARE_CONFIG_CHANGED);
RIL_UNSOL_(DC_RT_INFO_CHANGED);
RIL_UNSOL_(RADIO_CAPABILITY);
RIL_UNSOL_(ON_SS);
RIL_UNSOL_(STK_CC_ALPHA_NOTIFY);
default:
snprintf(unknown, sizeof(unknown), "RIL_UNSOL_%d", event);
return unknown;
}
}
const char *ril_radio_state_to_string(int radio_state)
{
#define RADIO_STATE_(name) case RADIO_STATE_##name: return #name
static char unknown[16];
switch (radio_state) {
RADIO_STATE_(OFF);
RADIO_STATE_(UNAVAILABLE);
RADIO_STATE_(SIM_NOT_READY);
RADIO_STATE_(SIM_LOCKED_OR_ABSENT);
RADIO_STATE_(SIM_READY);
RADIO_STATE_(RUIM_NOT_READY);
RADIO_STATE_(RUIM_READY);
RADIO_STATE_(RUIM_LOCKED_OR_ABSENT);
RADIO_STATE_(NV_NOT_READY);
RADIO_STATE_(NV_READY);
RADIO_STATE_(ON);
default:
snprintf(unknown, sizeof(unknown), "%d (?)", radio_state);
return unknown;
}
}
/* Returns enum access_technology or -1 on failure. */
int ril_parse_tech(const char *stech, int *ril_tech)
{
int access_tech = -1;
int tech = -1;
if (ril_parse_int(stech, 0, &tech)) {
switch (tech) {
case RADIO_TECH_GPRS:
case RADIO_TECH_GSM:
access_tech = ACCESS_TECHNOLOGY_GSM;
break;
case RADIO_TECH_EDGE:
access_tech = ACCESS_TECHNOLOGY_GSM_EGPRS;
break;
case RADIO_TECH_UMTS:
access_tech = ACCESS_TECHNOLOGY_UTRAN;
break;
case RADIO_TECH_HSDPA:
access_tech = ACCESS_TECHNOLOGY_UTRAN_HSDPA;
break;
case RADIO_TECH_HSUPA:
access_tech = ACCESS_TECHNOLOGY_UTRAN_HSUPA;
break;
case RADIO_TECH_HSPA:
case RADIO_TECH_HSPAP:
access_tech = ACCESS_TECHNOLOGY_UTRAN_HSDPA_HSUPA;
break;
case RADIO_TECH_LTE:
access_tech = ACCESS_TECHNOLOGY_EUTRAN;
break;
default:
DBG("Unknown RIL tech %s", stech);
/* no break */
case RADIO_TECH_IWLAN:
case RADIO_TECH_UNKNOWN:
tech = -1;
break;
}
}
if (ril_tech) {
*ril_tech = tech;
}
return access_tech;
}
gboolean ril_parse_mcc_mnc(const char *str, struct ofono_network_operator *op)
{
if (str) {
int i;
const char *ptr = str;
/* Three digit country code */
for (i = 0;
i < OFONO_MAX_MCC_LENGTH && *ptr && isdigit(*ptr);
i++) {
op->mcc[i] = *ptr++;
}
op->mcc[i] = 0;
if (i == OFONO_MAX_MCC_LENGTH) {
/* Usually 2 but sometimes 3 digit network code */
for (i = 0;
i < OFONO_MAX_MNC_LENGTH && *ptr && isdigit(*ptr);
i++) {
op->mnc[i] = *ptr++;
}
op->mnc[i] = 0;
if (i > 0) {
/*
* Sometimes MCC/MNC are followed by + and
* what looks like the technology code. This
* is of course completely undocumented.
*/
if (*ptr == '+') {
int tech = ril_parse_tech(ptr+1, NULL);
if (tech >= 0) {
op->tech = tech;
}
}
return TRUE;
}
}
}
return FALSE;
}
gboolean ril_parse_int(const char *str, int base, int *value)
{
gboolean ok = FALSE;
if (str && str[0]) {
char *str2 = g_strstrip(g_strdup(str));
char *end = str2;
long l;
errno = 0;
l = strtol(str2, &end, base);
ok = !*end && errno != ERANGE && l >= INT_MIN && l <= INT_MAX;
if (ok && value) {
*value = (int)l;
}
g_free(str2);
}
return ok;
}
/*
* Local Variables:
* mode: C
* c-basic-offset: 8
* indent-tabs-mode: t
* End:
*/

View File

@@ -0,0 +1,50 @@
/*
* oFono - Open Source Telephony - RIL-based devices
*
* Copyright (C) 2015-2017 Jolla Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#ifndef RIL_UTIL_H
#define RIL_UTIL_H
#include "ril_types.h"
struct ofono_network_operator;
const char *ril_error_to_string(int error);
const char *ril_request_to_string(guint request);
const char *ril_unsol_event_to_string(guint event);
const char *ril_radio_state_to_string(int radio_state);
int ril_parse_tech(const char *stech, int *ril_tech);
gboolean ril_parse_mcc_mnc(const char *str, struct ofono_network_operator *op);
gboolean ril_parse_int(const char *str, int base, int *value);
#define ril_error_init_ok(err) \
((err)->error = 0, (err)->type = OFONO_ERROR_TYPE_NO_ERROR)
#define ril_error_init_failure(err) \
((err)->error = 0, (err)->type = OFONO_ERROR_TYPE_FAILURE)
#define ril_error_init_sim_error(err,sw1,sw2) \
((err)->error = ((sw1) << 8)|(sw2), (err)->type = OFONO_ERROR_TYPE_SIM)
#define ril_error_ok(err) (ril_error_init_ok(err), err)
#define ril_error_failure(err) (ril_error_init_failure(err), err)
#define ril_error_sim(err,sw1,sw2) (ril_error_init_sim_error(err,sw1,sw2), err)
#endif /* RIL_UTIL_H */
/*
* Local Variables:
* mode: C
* c-basic-offset: 8
* indent-tabs-mode: t
* End:
*/

View File

@@ -0,0 +1,165 @@
/*
* oFono - Open Source Telephony - RIL-based devices
*
* Copyright (C) 2016-2017 Jolla Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "ril_vendor.h"
#include "ril_log.h"
struct ril_vendor_hook *ril_vendor_create_hook
(const struct ril_vendor_driver *vendor, GRilIoChannel *io,
const char *path, const struct ril_slot_config *config)
{
if (vendor) {
const void *data = vendor->driver_data;
/*
* NOTE: we are looking for the callback in the base but
* keeping the original driver data.
*/
while (!vendor->create_hook && vendor->base) {
vendor = vendor->base;
}
if (vendor->create_hook) {
return vendor->create_hook(data, io, path, config);
}
}
return NULL;
}
struct ril_vendor_hook *ril_vendor_hook_init(struct ril_vendor_hook *self,
const struct ril_vendor_hook_proc *proc)
{
self->proc = proc;
g_atomic_int_set(&self->ref_count, 1);
return self;
}
struct ril_vendor_hook *ril_vendor_hook_ref(struct ril_vendor_hook *self)
{
if (self) {
GASSERT(self->ref_count > 0);
g_atomic_int_inc(&self->ref_count);
}
return self;
}
static void ril_vendor_hook_free(struct ril_vendor_hook *self)
{
const struct ril_vendor_hook_proc *proc = self->proc;
while (!proc->free && proc->base) {
proc = proc->base;
}
if (proc->free) {
proc->free(self);
}
}
void ril_vendor_hook_unref(struct ril_vendor_hook *self)
{
if (self) {
GASSERT(self->ref_count > 0);
if (g_atomic_int_dec_and_test(&self->ref_count)) {
ril_vendor_hook_free(self);
}
}
}
void ril_vendor_get_defaults(const struct ril_vendor_driver *vendor,
struct ril_vendor_defaults *defaults)
{
if (vendor) {
while (!vendor->get_defaults && vendor->base) {
vendor = vendor->base;
}
if (vendor->get_defaults) {
vendor->get_defaults(defaults);
}
}
}
const char *ril_vendor_hook_request_to_string(struct ril_vendor_hook *self,
guint request)
{
if (self) {
const struct ril_vendor_hook_proc *proc = self->proc;
while (!proc->request_to_string && proc->base) {
proc = proc->base;
}
if (proc->request_to_string) {
return proc->request_to_string(self, request);
}
}
return NULL;
}
const char *ril_vendor_hook_event_to_string(struct ril_vendor_hook *self,
guint event)
{
if (self) {
const struct ril_vendor_hook_proc *proc = self->proc;
while (!proc->event_to_string && proc->base) {
proc = proc->base;
}
if (proc->event_to_string) {
return proc->event_to_string(self, event);
}
}
return NULL;
}
GRilIoRequest *ril_vendor_hook_data_call_req(struct ril_vendor_hook *self,
int tech, const char *profile, const char *apn,
const char *username, const char *password,
enum ril_auth auth, const char *proto)
{
if (self) {
const struct ril_vendor_hook_proc *proc = self->proc;
while (!proc->data_call_req && proc->base) {
proc = proc->base;
}
if (proc->data_call_req) {
return proc->data_call_req(self, tech, profile, apn,
username, password, auth, proto);
}
}
return NULL;
}
gboolean ril_vendor_hook_data_call_parse(struct ril_vendor_hook *self,
struct ril_data_call *call, int ver, GRilIoParser *rilp)
{
if (self) {
const struct ril_vendor_hook_proc *proc = self->proc;
while (!proc->data_call_parse && proc->base) {
proc = proc->base;
}
if (proc->data_call_parse) {
return proc->data_call_parse(self, call, ver, rilp);
}
}
return FALSE;
}
/*
* Local Variables:
* mode: C
* c-basic-offset: 8
* indent-tabs-mode: t
* End:
*/

Some files were not shown because too many files have changed in this diff Show More