Merge remote-tracking branch 'cros/upstream' into 'cros/master'

Contains the following patches:
4a0de586 base-call: if start() fails, always terminated (Aleksander Morgado)
2c0281aa call: disallow non-emergency calls when in emergency-only state (Aleksander Morgado)
d6f9d5e9 sim: load emergency numbers from EF_ECC (Aleksander Morgado)
1f6c0069 api,sim: new 'Emergency Numbers' property (Aleksander Morgado)
45cf1ba2 cinterion: don't cache voice support check AT commands (Aleksander Morgado)
57e78413 iface-modem-voice: always completely reinitialize the interface (Aleksander Morgado)
98066d24 broadband-modem: don't cache voice support check AT commands (Aleksander Morgado)
5fef1417 broadband-modem: ignore SIM-related errors in voice support check (Aleksander Morgado)
6347a7d7 base-call: catch terminated errors before ATD replies (Aleksander Morgado)
eaf66547 broadband-modem: keep ports context open while in-call (Aleksander Morgado)
c99f767f broadband-modem: reorder generic port context logic in sources (Aleksander Morgado)
ba1f3af3 broadband-modem: new generic ports_context_open() (Aleksander Morgado)
7c8d0d17 broadband-modem: skip redundant ATE0/AT+CMEE=1 settings (Aleksander Morgado)
657833a4 voice,api: new 'EmergencyOnly' boolean flag (Aleksander Morgado)
79718443 iface-modem-voice: all methods available even if not enabled (Aleksander Morgado)
ed3a1264 iface-modem-voice: call list setup during initialization (Aleksander Morgado)
00a39cd0 broadband-modem: voice interface available in failed/locked state (Aleksander Morgado)
27405a44 broadband-modem: new initialization step when failed/locked (Aleksander Morgado)
d555c4c4 iface-modem-simple: allow single ongoing Connect() attempt (Aleksander Morgado)
f228d0dd base-bearer,iface-modem-simple: log user requests to connect/disconnect (Aleksander Morgado)
667d1613 x22x: add support for the Alcatel X602D (Aleksander Morgado)
407cfa0c x22x: ignore unhandled URCs in the Alcatel X602D (Aleksander Morgado)
f30d3d46 ci: ignore errors on apt update (Aleksander Morgado)
5316e9e4 simtech: handle 'MISSED_CALL' URCs (Aleksander Morgado)
eb66e8ae simtech: setup USB audio channel when in-call (Aleksander Morgado)
e3a1364d core: allow flagging ports as 'audio' (Aleksander Morgado)
d61cb4a2 simtech: handle '+RXDTMF' URCs reporting DTMF tones (Aleksander Morgado)
345922ca simtech: handle non-standard '+CRING' URCs (Aleksander Morgado)
395b2217 simtech: handle 'VOICE CALL' URCs (Aleksander Morgado)
1a17996c iface-modem-voice: ignore unknown calls reported as terminated (Aleksander Morgado)
089faef8 modem-helpers: support reporting 'terminated' call state in +CLCC (Aleksander Morgado)
89c9566e simtech: implement +CLCC URC based call list management (Aleksander Morgado)
b99597b5 tests,helpers: minor alignment fix (Aleksander Morgado)
d5d0ed0b tests: print MM logs only on verbose test mode (Aleksander Morgado)
03223fe7 tests,sms: print PDUs only on verbose test mode (Aleksander Morgado)
3b18d21b tests: avoid g_print() and use g_debug() instead (Aleksander Morgado)
cc4e7f6c shared-qmi: fix NAS SSP support check during supported caps loading (Aleksander Morgado)
c8d715e5 api: set enum values not part of the API as private (Aleksander Morgado)
33140e1f mm-broadband-modem-mbim: fix incorrect log message (Eric Caruso)
6cbeb96a simtech: +CNSMOD value may have multiple digits (Aleksander Morgado)
e1d18afe simtech: add support for reporting LTE (Aleksander Morgado)
61f3c3c8 simtech: rework access tech value mapping (Aleksander Morgado)
7fcefc7a simtech: rework enabling/disabling unsolicited events (Aleksander Morgado)
1277ebb4 iface-modem: allow plugins to disable access technology polling (Aleksander Morgado)
45a238bc iface-modem: allow disabling signal quality polling during runtime (Aleksander Morgado)
c820e02f simtech: enable +CSQ URC support (Aleksander Morgado)
765f26a4 iface-modem: don't log error if it's in progress (Aleksander Morgado)
1f6f9eec simtech: keep access tech URC regex in private struct (Aleksander Morgado)
c98a1a9d simtech: disable CMER/CIND support explicitly (Aleksander Morgado)
feb6c826 broadband-modem: allow disabling +CIND URC setup (Aleksander Morgado)
81795f30 simtech: implement GPS support with AT+CGPS (Aleksander Morgado)
583d53a7 simtech: port type hints for the SIM7000/SIM7600 family (Aleksander Morgado)
eeb1f739 simtech: remove unused ID_MM_SIMTECH_TAGGED tag (Aleksander Morgado)
55c3f7d3 systemd: always start MM after polkit service if enabling policy (Aleksander Morgado)
803c7705 broadband-modem-qmi: fix when >1 PRI images for the same modem image (Aleksander Morgado)
227c2907 mmcli,firmware: don't use tabs when printing human-friendly list (Aleksander Morgado)
6977b41a broadband-modem-qmi: prefer ASCII unique IDs (Aleksander Morgado)
a55543d1 broadband-modem-qmi: fix listing images when 'Get Stored Image Info' is unsupported (Aleksander Morgado)
1b29f752 broadband-modem-qmi: move pri/modem pair list building to separate method (Aleksander Morgado)
7986b273 broadband-modem-qmi: move pri/modem list index lookup to separate method (Aleksander Morgado)
5b8da2e1 broadband-modem-qmi: add note about index_of_running_image known issue (Aleksander Morgado)
66192288 broadband-modem-qmi: fix minor typo in comment (Aleksander Morgado)
3f15293a daemon: register G_IO_ERROR_CANCELLED as "Cancelled" in DBus (Aleksander Morgado)
cf0d3f36 iface-modem: avoid using MM_CORE_ERROR_CANCELLED (Aleksander Morgado)
651bfd62 port-serial: avoid using MM_CORE_ERROR_CANCELLED (Aleksander Morgado)
fa453a17 iface-modem-voice: avoid using MM_CORE_ERROR_CANCELLED (Aleksander Morgado)
cff3be23 broadband-modem: avoid using MM_CORE_ERROR_CANCELLED (Aleksander Morgado)
7974933d broadband-modem-mbim: avoid using MM_CORE_ERROR_CANCELLED (Aleksander Morgado)
c0e1bde0 base-modem-at: avoid using MM_CORE_ERROR_CANCELLED (Aleksander Morgado)
def5c76c huawei,bearer: avoid using MM_CORE_ERROR_CANCELLED (Aleksander Morgado)
6de9c8cb base-bearer: avoid using MM_CORE_ERROR_CANCELLED (Aleksander Morgado)
15b81560 iface-modem-simple: fix Simple.Disconnect() when bearer path given (Aleksander Morgado)
3a9c5531 libmm-glib,oma: avoid plural in type (Aleksander Morgado)
19652e10 libmm-glib,call: fix typo in documentation (Aleksander Morgado)
a64223ca po: update Polish translation (Piotr Drąg)
0a85254d cli: fix typo when looking for a specific call fails (Aleksander Morgado)
4352c273 po: updated after new Time policy setup (Aleksander Morgado)
8a652179 policy: USSD policy requires user authentication in strict mode (Aleksander Morgado)
958c2434 polkit,conf: trivial comment update regarding Signal.Setup() (Aleksander Morgado)
1cd24a31 iface-modem-firmware: use the explicit Firmware policy (Aleksander Morgado)
110f6fd0 polkit,conf: add missing firmware management methods (Aleksander Morgado)
2e5af74d polkit,conf: add missing OMA methods (Aleksander Morgado)
7a7b3aa5 polkit,time: protect GetNetworkTime() with a new 'Time' policy rule (Aleksander Morgado)
be2500b0 polkit,conf: add missing supplementary voice service methods (Aleksander Morgado)
01acd9a0 polkit,conf: add missing InjectAssistanceData (Aleksander Morgado)
9e24d1c1 polkit,conf: add missing SetInitialEpsBearerSettings (Aleksander Morgado)
614c7fbc polkit,conf: add missing SetEpsUeModeOperation (Aleksander Morgado)
f2182a73 polkit,conf: add missing SetCurrentCapabilities (Aleksander Morgado)
3696a009 polkit,conf: add missing SetPowerState (Aleksander Morgado)
d3e75eec policy,conf: use SetCurrentBands instead of SetBands (Aleksander Morgado)
e21e7ddf policy: Use SetCurrentModes instead of SetAllowedModes (Mohammed Sadiq)
79a39656 broadband-modem: shutdown firmware interface on dispose() (Aleksander Morgado)
dcf50efd ublox: fix calling setup_unsolicited_events_finish() (Aleksander Morgado)
a1148f87 cinterion: fix calling setup_unsolicited_events_finish() (Aleksander Morgado)
c8af22ab cli,messaging: trivial fix in comment (Aleksander Morgado)
6c9027b2 docs,libmm-glib: add missing references to call waiting query/setup (Aleksander Morgado)
16145c29 sms-part-3gpp: SMS timestamp in ISO8601 format (amol.lad)

Change-Id: I81f3c5805b6bd8adab694e3440a526b9e4e435a4
diff --git a/OWNERS b/OWNERS
new file mode 100644
index 0000000..6f7554b
--- /dev/null
+++ b/OWNERS
@@ -0,0 +1,3 @@
+set noparent
+akhouderchah@chromium.org
+ejcaruso@chromium.org
diff --git a/PRESUBMIT.cfg b/PRESUBMIT.cfg
new file mode 100644
index 0000000..51d8dd6
--- /dev/null
+++ b/PRESUBMIT.cfg
@@ -0,0 +1,9 @@
+# This sample config file disables all of the ChromiumOS source style checks.
+# Comment out the disable-flags for any checks you want to leave enabled.
+
+[Hook Overrides]
+stray_whitespace_check: false
+long_line_check: false
+cros_license_check: false
+tab_check: false
+
diff --git a/README.chromium b/README.chromium
new file mode 100644
index 0000000..10c881e
--- /dev/null
+++ b/README.chromium
@@ -0,0 +1,20 @@
+DESCRIPTION="Broadband modem support daemon (new API)"
+HOMEPAGE="http://projects.gnome.org/NetworkManager/"
+UPSTREAM_REPO="git://anongit.freedesktop.org/ModemManager/ModemManager"
+LOCAL_GIT_REPO="https://chromium.googlesource.com/chromiumos/third_party/modemmanager-next.git"
+UPSTREAM_BUGSDB="https://bugzilla.gnome.org/enter_bug.cgi?product=NetworkManager"
+LOCAL_BUGSDB="http://crosbug.com"
+LICENSE="GPLv2"
+LICENSE_FILE="COPYING"
+
+Description:
+
+ModemManager provides a DBus interface to control broadband modem
+devices. The intended user is a network manager program, such as
+NetworkManager, flimflam, or shill.
+
+This repository mirrors the 0.6-api branch of the upstream repository
+while it is under active development as a branch.
+
+Local changes should be minimal, but support for particular modems may
+make it here before they make it upstream.
diff --git a/plugins/novatel/mm-broadband-modem-novatel-lte.c b/plugins/novatel/mm-broadband-modem-novatel-lte.c
index 7b6396d..539689c 100644
--- a/plugins/novatel/mm-broadband-modem-novatel-lte.c
+++ b/plugins/novatel/mm-broadband-modem-novatel-lte.c
@@ -164,6 +164,43 @@
 }
 
 /*****************************************************************************/
+/* Load current capabilities (Modem interface) */
+
+static MMModemCapability
+load_current_capabilities_finish (MMIfaceModem *self,
+                                  GAsyncResult *res,
+                                  GError **error)
+{
+    MMModemCapability caps;
+    gchar *caps_str;
+
+    /* Constrain the modem capabilities to LTE only.
+     * TODO(benchan): Remove this constraint. */
+    caps = MM_MODEM_CAPABILITY_LTE;
+    caps_str = mm_modem_capability_build_string_from_mask (caps);
+    mm_dbg ("loaded current capabilities: %s", caps_str);
+    g_free (caps_str);
+    return caps;
+}
+
+static void
+load_current_capabilities (MMIfaceModem *self,
+                           GAsyncReadyCallback callback,
+                           gpointer user_data)
+{
+    GSimpleAsyncResult *result;
+
+    mm_dbg ("loading (Novatel LTE) current capabilities...");
+
+    result = g_simple_async_result_new (G_OBJECT (self),
+                                        callback,
+                                        user_data,
+                                        load_current_capabilities);
+    g_simple_async_result_complete_in_idle (result);
+    g_object_unref (result);
+}
+
+/*****************************************************************************/
 /* Load own numbers (Modem interface) */
 
 static GStrv
@@ -640,6 +677,49 @@
 }
 
 /*****************************************************************************/
+/* Initializing the modem (during first enabling) */
+
+static const MMBaseModemAtCommand modem_init_sequence[] = {
+    /* Init command. ITU rec v.250 (6.1.1) says:
+     *   The DTE should not include additional commands on the same command line
+     *   after the Z command because such commands may be ignored.
+     * So run ATZ alone.
+     */
+    { "Z",       6, FALSE, mm_base_modem_response_processor_no_result_continue },
+
+    /* Temporarily force the modem into LTE only mode to prevent it from falling
+     * back to 3G.
+     * TODO(benchan): Remove this constraint
+     */
+    { "$NWPREFMODE=30", 6, FALSE, mm_base_modem_response_processor_continue_on_error },
+
+    { NULL }
+};
+
+static gboolean
+enabling_modem_init_finish (MMBroadbandModem *self,
+                            GAsyncResult *res,
+                            GError **error)
+{
+    return !!mm_base_modem_at_command_full_finish (MM_BASE_MODEM (self), res, error);
+}
+
+static void
+enabling_modem_init (MMBroadbandModem *self,
+                     GAsyncReadyCallback callback,
+                     gpointer user_data)
+{
+    mm_base_modem_at_sequence_full (MM_BASE_MODEM (self),
+                                    mm_base_modem_peek_port_primary (MM_BASE_MODEM (self)),
+                                    modem_init_sequence,
+                                    NULL,  /* response_processor_context */
+                                    NULL,  /* response_processor_context_free */
+                                    NULL,  /* cancellable */
+                                    callback,
+                                    user_data);
+}
+
+/*****************************************************************************/
 
 MMBroadbandModemNovatelLte *
 mm_broadband_modem_novatel_lte_new (const gchar *device,
@@ -654,6 +734,11 @@
                          MM_BASE_MODEM_PLUGIN, plugin,
                          MM_BASE_MODEM_VENDOR_ID, vendor_id,
                          MM_BASE_MODEM_PRODUCT_ID, product_id,
+                         /* Temporarily allows only EPS network registration status */
+                         /* TODO(benchan): Remove this constraint */
+                         MM_IFACE_MODEM_3GPP_CS_NETWORK_SUPPORTED, FALSE,
+                         MM_IFACE_MODEM_3GPP_PS_NETWORK_SUPPORTED, FALSE,
+                         MM_IFACE_MODEM_3GPP_EPS_NETWORK_SUPPORTED, TRUE,
                          NULL);
 }
 
@@ -673,6 +758,8 @@
     iface->create_sim_finish = modem_create_sim_finish;
     iface->modem_after_sim_unlock = modem_after_sim_unlock;
     iface->modem_after_sim_unlock_finish = modem_after_sim_unlock_finish;
+    iface->load_current_capabilities = load_current_capabilities;
+    iface->load_current_capabilities_finish = load_current_capabilities_finish;
     iface->load_own_numbers = load_own_numbers;
     iface->load_own_numbers_finish = load_own_numbers_finish;
     iface->load_supported_bands = load_supported_bands;
@@ -698,4 +785,8 @@
 static void
 mm_broadband_modem_novatel_lte_class_init (MMBroadbandModemNovatelLteClass *klass)
 {
+    MMBroadbandModemClass *broadband_modem_class = MM_BROADBAND_MODEM_CLASS (klass);
+
+    broadband_modem_class->enabling_modem_init = enabling_modem_init;
+    broadband_modem_class->enabling_modem_init_finish = enabling_modem_init_finish;
 }
diff --git a/plugins/tests/test-fixture.c b/plugins/tests/test-fixture.c
index d496fee..7cf065f 100644
--- a/plugins/tests/test-fixture.c
+++ b/plugins/tests/test-fixture.c
@@ -142,7 +142,7 @@
             break;
 
         /* Blocking wait */
-        g_assert_cmpuint (wait_time, <=, 20);
+        g_assert_cmpuint (wait_time, <=, 120);
         wait_time++;
         sleep (1);
     }