~ubuntu-branches/ubuntu/utopic/ofono/utopic-proposed

« back to all changes in this revision

Viewing changes to plugins/mtk.c

  • Committer: Package Import Robot
  • Author(s): Ubuntu daily release, Alfonso Sanchez-Beato, Tony Espy, Ubuntu daily release
  • Date: 2014-09-26 17:34:10 UTC
  • mfrom: (1.3.26)
  • Revision ID: package-import@ubuntu.com-20140926173410-dd4yzlutz0mf37n6
Tags: 1.12.bzr6878+14.10.20140926-0ubuntu1
[ Alfonso Sanchez-Beato ]
* include, plugins/mtk.c, src/modem.c,sim.c: Fix PUK crash (LP: #1365481)
  If the SIM gets locked in particular sequence, ofono will crash
  while trying to free the list of SIM SPN watch events ( which
  have already been freed ).  MTK fix is a bit more involved than
  the stanard RIL logic.

* plugins/mtk.c,ril.c: Show emergency numbers in flight-mode (LP: #1366188)
  Modify plugin logic to create the SimManager interface even if
  no SIM is present.

* gril, unit: fix indicator-network crash (LP: #1368675)
  RIL defines a set of network registration states for emergency
  calling that don't map directly to ofono's states.  This results
  in NetworkRegistration Status not being set at all, which in
  turn crashes the indicator.

* rilmodem/gprs.c: fix crash due to stale timer event (LP: # 1373351)
  A 5s timer is set to retry a STATUS request to RIL, however if
  FlightMode is enabled, the gprs atom is destroyed, and the pending
  timer callback has a stale gprs reference.  Now the timer id is
  stored, and when the atom destroyed, the timer event is cancelled.

* mtkmodem/radio-setttings.c: fix RadioSettings creation (LP: #1374029 )
  If the MTK modem returns a RADIO_NOT_AVAIL error in response
  to a FastDormany RIL request, the RadioSetting initialization
  callback sequence is broken, and thus the RadioSettings interface
  isn't created.  This in turn prevents powerd from enabling
  FastDorancy whenever the screen is turned off, and also has
  implications for system-settings too.

[ Tony Espy ]
* plugins/ubuntu-apndb.c: allow MMS APNs w/out proxy (LP: #1362008)
  Prior to this change, MMS APNs w/out a proxy were skipped.
  Now APNs are skipped if message center is missing, which makes
  more sense.

[ Ubuntu daily release ]
* New rebuild forced

Show diffs side-by-side

added added

removed removed

Lines of Context:
94
94
        int slot;
95
95
        struct ril_sim_data sim_data;
96
96
        struct ofono_devinfo *devinfo;
 
97
        struct ofono_voicecall *voicecall;
 
98
        struct ofono_call_volume *callvolume;   
97
99
        struct cb_data *pending_online_cbd;
98
100
        ofono_bool_t pending_online;
99
101
        ofono_bool_t gprs_attach;
100
102
        int rild_connect_retries;
 
103
        struct ofono_sms *sms;
 
104
        struct ofono_netreg *netreg;
 
105
        struct ofono_ussd *ussd;
 
106
        struct ofono_call_settings *call_settings;
 
107
        struct ofono_call_forwarding *call_forwarding;
 
108
        struct ofono_call_barring *call_barring;
 
109
        struct ofono_gprs *gprs;
 
110
        struct ofono_message_waiting *message_waiting;
101
111
};
102
112
 
103
113
/*
377
387
        DBG("slot %d", ril->slot);
378
388
}
379
389
 
 
390
/*
 
391
 * sim_state_watch listens to SIM state changes and creates/removes atoms
 
392
 * accordingly. This is needed because we cannot rely on the modem core code,
 
393
 * which handles modem state transitions, to do this due to the SIM not being
 
394
 * accessible in the offline state for mtk modems. This causes a mismatch
 
395
 * between what the core thinks it can do in some states and what the mtk modem
 
396
 * can really do in those. This is a workaround to solve that.
 
397
 */
380
398
static void sim_state_watch(enum ofono_sim_state new_state, void *data)
381
399
{
 
400
        struct ofono_modem *modem = data;
 
401
        struct mtk_data *ril = ofono_modem_get_data(modem);
 
402
 
382
403
        if (new_state == OFONO_SIM_STATE_READY) {
383
 
                struct ofono_modem *modem = data;
384
 
                struct mtk_data *ril = ofono_modem_get_data(modem);
385
 
                struct ofono_gprs *gprs;
386
404
                struct ofono_gprs_context *gc;
387
 
                struct ofono_message_waiting *mw;
388
405
                struct mtk_gprs_data gprs_data = { ril->modem, modem };
389
406
                struct ril_gprs_context_data inet_ctx =
390
407
                        { ril->modem, OFONO_GPRS_CONTEXT_TYPE_INTERNET };
399
416
                 *  - stk ( SIM toolkit )
400
417
                 *  - radio_settings
401
418
                 */
402
 
                ofono_sms_create(modem, OFONO_RIL_VENDOR_MTK,
403
 
                                        RILMODEM, ril->modem);
 
419
                ril->sms = ofono_sms_create(modem, OFONO_RIL_VENDOR_MTK,
 
420
                                                RILMODEM, ril->modem);
404
421
 
405
422
                /* netreg needs access to the SIM (SPN, SPDI) */
406
 
                ofono_netreg_create(modem, OFONO_RIL_VENDOR_MTK,
407
 
                                        RILMODEM, ril->modem);
408
 
                ofono_ussd_create(modem, OFONO_RIL_VENDOR_MTK,
409
 
                                        RILMODEM, ril->modem);
410
 
                ofono_call_settings_create(modem, OFONO_RIL_VENDOR_MTK,
411
 
                                                RILMODEM, ril->modem);
412
 
                ofono_call_forwarding_create(modem, OFONO_RIL_VENDOR_MTK,
413
 
                                                RILMODEM, ril->modem);
414
 
                ofono_call_barring_create(modem, OFONO_RIL_VENDOR_MTK,
415
 
                                                RILMODEM, ril->modem);
 
423
                ril->netreg = ofono_netreg_create(modem, OFONO_RIL_VENDOR_MTK,
 
424
                                                        RILMODEM, ril->modem);
 
425
                ril->ussd = ofono_ussd_create(modem, OFONO_RIL_VENDOR_MTK,
 
426
                                                RILMODEM, ril->modem);
 
427
                ril->call_settings =
 
428
                        ofono_call_settings_create(modem, OFONO_RIL_VENDOR_MTK,
 
429
                                                        RILMODEM, ril->modem);
 
430
                ril->call_forwarding =
 
431
                        ofono_call_forwarding_create(modem,
 
432
                                                        OFONO_RIL_VENDOR_MTK,
 
433
                                                        RILMODEM, ril->modem);
 
434
                ril->call_barring =
 
435
                        ofono_call_barring_create(modem, OFONO_RIL_VENDOR_MTK,
 
436
                                                        RILMODEM, ril->modem);
416
437
 
417
 
                gprs = ofono_gprs_create(modem, OFONO_RIL_VENDOR_MTK,
 
438
                ril->gprs = ofono_gprs_create(modem, OFONO_RIL_VENDOR_MTK,
418
439
                                                MTKMODEM, &gprs_data);
419
440
 
420
441
                gc = ofono_gprs_context_create(modem, OFONO_RIL_VENDOR_MTK,
422
443
                if (gc) {
423
444
                        ofono_gprs_context_set_type(gc,
424
445
                                        OFONO_GPRS_CONTEXT_TYPE_INTERNET);
425
 
                        ofono_gprs_add_context(gprs, gc);
 
446
                        ofono_gprs_add_context(ril->gprs, gc);
426
447
                }
427
448
 
428
449
                gc = ofono_gprs_context_create(modem, OFONO_RIL_VENDOR_MTK,
430
451
                if (gc) {
431
452
                        ofono_gprs_context_set_type(gc,
432
453
                                        OFONO_GPRS_CONTEXT_TYPE_MMS);
433
 
                        ofono_gprs_add_context(gprs, gc);
434
 
                }
435
 
 
436
 
                mw = ofono_message_waiting_create(modem);
437
 
                if (mw)
438
 
                        ofono_message_waiting_register(mw);
 
454
                        ofono_gprs_add_context(ril->gprs, gc);
 
455
                }
 
456
 
 
457
                ril->message_waiting = ofono_message_waiting_create(modem);
 
458
                if (ril->message_waiting)
 
459
                        ofono_message_waiting_register(ril->message_waiting);
 
460
 
 
461
        } else if (new_state == OFONO_SIM_STATE_LOCKED_OUT) {
 
462
 
 
463
                DBG("SIM locked, removing atoms");
 
464
 
 
465
                if (ril->message_waiting) {
 
466
                        ofono_message_waiting_remove(ril->message_waiting);
 
467
                        ril->message_waiting = NULL;
 
468
                }
 
469
                if (ril->gprs) {
 
470
                        ofono_gprs_remove(ril->gprs);
 
471
                        ril->gprs = NULL;
 
472
                }
 
473
                if (ril->call_barring) {
 
474
                        ofono_call_barring_remove(ril->call_barring);
 
475
                        ril->call_barring = NULL;
 
476
                }
 
477
                if (ril->call_forwarding) {
 
478
                        ofono_call_forwarding_remove(ril->call_forwarding);
 
479
                        ril->call_forwarding = NULL;
 
480
                }
 
481
                if (ril->call_settings) {
 
482
                        ofono_call_settings_remove(ril->call_settings);
 
483
                        ril->call_settings = NULL;
 
484
                }
 
485
                if (ril->ussd) {
 
486
                        ofono_ussd_remove(ril->ussd);
 
487
                        ril->ussd = NULL;
 
488
                }
 
489
                if (ril->netreg) {
 
490
                        ofono_netreg_remove(ril->netreg);
 
491
                        ril->netreg = NULL;
 
492
                }
 
493
                if (ril->sms) {
 
494
                        ofono_sms_remove(ril->sms);
 
495
                        ril->sms = NULL;
 
496
                }
439
497
        }
440
498
}
441
499
 
453
511
                                        RILMODEM, &ril->sim_data);
454
512
        g_assert(ril->sim != NULL);
455
513
 
456
 
        /* Create interfaces useful for emergency calls */
457
 
        ofono_voicecall_create(modem, OFONO_RIL_VENDOR_MTK,
458
 
                                        MTKMODEM, ril->modem);
459
 
        ofono_call_volume_create(modem, OFONO_RIL_VENDOR_MTK,
460
 
                                        RILMODEM, ril->modem);
461
 
 
462
514
        /* Radio settings does not depend on the SIM */
463
515
        ofono_radio_settings_create(modem, OFONO_RIL_VENDOR_MTK,
464
516
                                        MTKMODEM, ril->modem);
658
710
        }
659
711
}
660
712
 
 
713
static void create_atoms_on_connection(struct ofono_modem *modem)
 
714
{
 
715
        struct mtk_data *ril = ofono_modem_get_data(modem);
 
716
 
 
717
        ril->devinfo = ofono_devinfo_create(modem, OFONO_RIL_VENDOR_MTK,
 
718
                                                RILMODEM, ril->modem);
 
719
 
 
720
        /* Create interfaces useful for emergency calls */
 
721
        ril->voicecall = ofono_voicecall_create(modem, OFONO_RIL_VENDOR_MTK,
 
722
                                                MTKMODEM, ril->modem);
 
723
        ril->callvolume = ofono_call_volume_create(modem, OFONO_RIL_VENDOR_MTK,
 
724
                                                        RILMODEM, ril->modem);
 
725
}
 
726
 
 
727
static void remove_atoms_on_disconnection(struct ofono_modem *modem)
 
728
{
 
729
        struct mtk_data *ril = ofono_modem_get_data(modem);
 
730
 
 
731
        ofono_call_volume_remove(ril->callvolume);
 
732
        ril->callvolume = NULL;
 
733
        ofono_voicecall_remove(ril->voicecall);
 
734
        ril->voicecall = NULL;
 
735
        ofono_devinfo_remove(ril->devinfo);
 
736
        ril->devinfo = NULL;
 
737
}
 
738
 
661
739
static gboolean mtk_connected(gpointer user_data)
662
740
{
663
741
        struct ofono_modem *modem = (struct ofono_modem *) user_data;
669
747
 
670
748
        ofono_modem_set_powered(modem, TRUE);
671
749
 
672
 
        ril->devinfo = ofono_devinfo_create(modem, OFONO_RIL_VENDOR_MTK,
673
 
                                                RILMODEM, ril->modem);
 
750
        create_atoms_on_connection(modem);
674
751
 
675
752
        /* Call the function just once */
676
753
        return FALSE;
686
763
        if (create_gril(modem) < 0)
687
764
                return TRUE;
688
765
 
689
 
        ril->devinfo = ofono_devinfo_create(modem, OFONO_RIL_VENDOR_MTK,
690
 
                                                RILMODEM, ril->modem);
 
766
        create_atoms_on_connection(modem);
691
767
 
692
768
        if (ril->pending_cb)
693
769
                ril->pending_cb(ril->pending_cbd);
705
781
 
706
782
        DBG("slot %d", ril->slot);
707
783
 
708
 
        /* Uses old gril object, remove and recreate later */
709
 
        ofono_devinfo_remove(ril->devinfo);
 
784
        /* Atoms use old gril object, remove and recreate later */
 
785
        remove_atoms_on_disconnection(modem);
710
786
 
711
787
        g_ril_unref(ril->modem);
712
788
        ril->modem = NULL;
804
880
                g_timeout_add_seconds(RILD_CONNECT_RETRY_TIME_S,
805
881
                                        connect_rild, modem);
806
882
 
 
883
        /* We handle SIM states due to MTK peculiarities */
 
884
        ofono_modem_set_driver_watches_sim(modem, TRUE);
 
885
 
807
886
        /*
808
887
         * We will mark the modem as powered when we receive an event that
809
888
         * confirms that the radio is in a state different from unavailable