Add functions to notify core of SIM insertion/removal/proactive command.
RFC PATCH 1/5 Add functions to notify core of SIM insertion/removal/proactive command.
Make every plugin generate a sim inserted event on start. For devices with removable SIM card, the event should be emitted after the plugin detects it.
--- include/sim.h | 12 +++++- plugins/atgen.c | 5 ++- plugins/calypso.c | 5 ++- plugins/em770.c | 5 ++- plugins/g1.c | 5 ++- plugins/hso.c | 5 ++- plugins/huawei.c | 5 ++- plugins/mbm.c | 5 ++- plugins/palmpre.c | 5 ++- plugins/phonesim.c | 5 ++- plugins/ste.c | 5 ++- src/sim.c | 113 +++++++++++++++++++++++++++++++++++++++++----------- 12 files changed, 141 insertions(+), 34 deletions(-)
include/sim.h +11 -1
@@ -179,8 +179,18 @@ unsigned int ofono_sim_add_ready_watch(struct ofono_sim *sim,void ofono_sim_remove_ready_watch (struct ofono_sim *sim,unsigned int id); +unsigned int ofono_sim_add_removed_watch (struct ofono_sim *sim, +ofono_sim_ready_notify_cb_t cb, +void *data,ofono_destroy_func destroy); + +void ofono_sim_remove_removed_watch (struct ofono_sim *sim,unsigned int id); +int ofono_sim_get_ready (struct ofono_sim *sim); -void ofono_sim_set_ready (struct ofono_sim *sim); + +void ofono_sim_inserted (struct ofono_sim *sim); +void ofono_sim_removed (struct ofono_sim *sim); +void ofono_sim_proactive_command_notify (struct ofono_sim *sim, +int length,const guint8 *pdu);/* This will queue an operation to read all available records with id from the * SIM. Callback cb will be called every time a record has been read, or once
plugins/atgen.c +4 -1
@@ -156,12 +156,15 @@ static int atgen_disable(struct ofono_modem *modem)static void atgen_pre_sim (struct ofono_modem *modem) {GAtChat *chat =ofono_modem_get_data (modem); +struct ofono_sim *sim;DBG ("%p" , modem);ofono_devinfo_create (modem,0 ,"atmodem" , chat); -ofono_sim_create (modem,0 ,"atmodem" , chat); + sim =ofono_sim_create (modem,0 ,"atmodem" , chat);ofono_voicecall_create (modem,0 ,"atmodem" , chat); + +ofono_sim_inserted (sim); }static void atgen_post_sim (struct ofono_modem *modem)
plugins/calypso.c +4 -1
@@ -431,12 +431,15 @@ static int calypso_disable(struct ofono_modem *modem)static void calypso_pre_sim (struct ofono_modem *modem) {struct calypso_data *data =ofono_modem_get_data (modem); +struct ofono_sim *sim;DBG ("" );ofono_devinfo_create (modem,0 ,"atmodem" , data->dlcs[AUX_DLC ]); -ofono_sim_create (modem,0 ,"atmodem" , data->dlcs[AUX_DLC ]); + sim =ofono_sim_create (modem,0 ,"atmodem" , data->dlcs[AUX_DLC ]);ofono_voicecall_create (modem,0 ,"calypsomodem" , data->dlcs[VOICE_DLC ]); + +ofono_sim_inserted (sim); }static void calypso_post_sim (struct ofono_modem *modem)
plugins/em770.c +4 -1
@@ -172,12 +172,15 @@ static int em770_disable(struct ofono_modem *modem)static void em770_pre_sim (struct ofono_modem *modem) {struct em770_data *data =ofono_modem_get_data (modem); +struct ofono_sim *sim;DBG ("%p" , modem);ofono_devinfo_create (modem,0 ,"atmodem" , data->chat); -ofono_sim_create (modem,0 ,"atmodem" , data->chat); + sim =ofono_sim_create (modem,0 ,"atmodem" , data->chat);ofono_voicecall_create (modem,0 ,"atmodem" , data->chat); + +ofono_sim_inserted (sim); }static void em770_post_sim (struct ofono_modem *modem)
plugins/g1.c +4 -1
@@ -156,12 +156,15 @@ static int g1_disable(struct ofono_modem *modem)static void g1_pre_sim (struct ofono_modem *modem) {GAtChat *chat =ofono_modem_get_data (modem); +struct ofono_sim *sim;DBG ("" );ofono_devinfo_create (modem,0 ,"atmodem" , chat); -ofono_sim_create (modem,0 ,"atmodem" , chat); + sim =ofono_sim_create (modem,0 ,"atmodem" , chat);ofono_voicecall_create (modem,0 ,"atmodem" , chat); + +ofono_sim_inserted (sim); }static void g1_post_sim (struct ofono_modem *modem)
plugins/hso.c +4 -1
@@ -198,11 +198,14 @@ static int hso_disable(struct ofono_modem *modem)static void hso_pre_sim (struct ofono_modem *modem) {struct hso_data *data =ofono_modem_get_data (modem); +struct ofono_sim *sim;DBG ("%p" , modem);ofono_devinfo_create (modem,0 ,"atmodem" , data->control); -ofono_sim_create (modem,0 ,"atmodem" , data->control); + sim =ofono_sim_create (modem,0 ,"atmodem" , data->control); + +ofono_sim_inserted (sim); }static void hso_post_sim (struct ofono_modem *modem)
plugins/huawei.c +4 -1
@@ -163,12 +163,15 @@ static int huawei_disable(struct ofono_modem *modem)static void huawei_pre_sim (struct ofono_modem *modem) {struct huawei_data *data =ofono_modem_get_data (modem); +struct ofono_sim *sim;DBG ("%p" , modem);ofono_devinfo_create (modem,0 ,"atmodem" , data->chat); -ofono_sim_create (modem,0 ,"atmodem" , data->chat); + sim =ofono_sim_create (modem,0 ,"atmodem" , data->chat);ofono_voicecall_create (modem,0 ,"atmodem" , data->chat); + +ofono_sim_inserted (sim); }static void huawei_post_sim (struct ofono_modem *modem)
plugins/mbm.c +4 -1
@@ -272,12 +272,15 @@ static int mbm_disable(struct ofono_modem *modem)static void mbm_pre_sim (struct ofono_modem *modem) {struct mbm_data *data =ofono_modem_get_data (modem); +struct ofono_sim *sim;DBG ("%p" , modem);ofono_devinfo_create (modem,0 ,"atmodem" , data->chat); -ofono_sim_create (modem,0 ,"atmodem" , data->chat); + sim =ofono_sim_create (modem,0 ,"atmodem" , data->chat);ofono_voicecall_create (modem,0 ,"atmodem" , data->chat); + +ofono_sim_inserted (sim); }static void mbm_post_sim (struct ofono_modem *modem)
plugins/palmpre.c +4 -1
@@ -170,13 +170,16 @@ static int palmpre_disable(struct ofono_modem *modem)static void palmpre_pre_sim (struct ofono_modem *modem) {struct palmpre_data *data =ofono_modem_get_data (modem); +struct ofono_sim *sim;DBG ("%p" , modem);ofono_devinfo_create (modem,0 ,"atmodem" , data->chat); -ofono_sim_create (modem,OFONO_VENDOR_QUALCOMM_MSM ,"atmodem" , + sim =ofono_sim_create (modem,OFONO_VENDOR_QUALCOMM_MSM ,"atmodem" , data->chat);ofono_voicecall_create (modem,0 ,"atmodem" , data->chat); + +ofono_sim_inserted (sim); }static void palmpre_post_sim (struct ofono_modem *modem)
plugins/phonesim.c +4 -1
@@ -277,16 +277,19 @@ static int phonesim_disable(struct ofono_modem *modem)static void phonesim_pre_sim (struct ofono_modem *modem) {struct phonesim_data *data =ofono_modem_get_data (modem); +struct ofono_sim *sim;DBG ("%p" , modem);ofono_devinfo_create (modem,0 ,"atmodem" , data->chat); -ofono_sim_create (modem,0 ,"atmodem" , data->chat); + sim =ofono_sim_create (modem,0 ,"atmodem" , data->chat);if (data->calypso)ofono_voicecall_create (modem,0 ,"calypsomodem" , data->chat);else ofono_voicecall_create (modem,0 ,"atmodem" , data->chat); + +ofono_sim_inserted (sim); }static void phonesim_post_sim (struct ofono_modem *modem)
plugins/ste.c +4 -1
@@ -208,12 +208,15 @@ static int ste_disable(struct ofono_modem *modem)static void ste_pre_sim (struct ofono_modem *modem) {struct ste_data *data =ofono_modem_get_data (modem); +struct ofono_sim *sim;DBG ("%p" , modem);ofono_devinfo_create (modem,0 ,"atmodem" , data->chat); -ofono_sim_create (modem,0 ,"atmodem" , data->chat); + sim =ofono_sim_create (modem,0 ,"atmodem" , data->chat);ofono_voicecall_create (modem,0 ,"stemodem" , data->chat); + +ofono_sim_inserted (sim); }static void ste_post_sim (struct ofono_modem *modem)
src/sim.c +90 -23
165 lines not on this page · raw message
Signature · 1 line
1.6.1
Hi Andrew,
include/sim.h unsigned int ofono_sim_add_ready_watch(struct ofono_sim *sim,
Quoted 9 lines
Make every plugin generate a sim inserted event on start. For devices with removable SIM card, the event should be emitted after the plugin detects it.
---include/sim.h +5
-0+unsigned int ofono_sim_add_removed_watch (struct ofono_sim *sim, +ofono_sim_ready_notify_cb_t cb, +void *data,ofono_destroy_func destroy); + +void ofono_sim_remove_removed_watch(struct ofono_sim *sim, unsigned int
So let us refactor the existing SIM ready events and the SIM removed events into a single set of watch functions with a state enum.
e.g. something like
enum ofono_sim_state {
OFONO_SIM_STATE_NOT_PRESENT,
OFONO_SIM_STATE_INSERTED,
OFONO_SIM_STATE_READY,
};
include/sim.h unsigned int ofono_sim_add_ready_watch(struct ofono_sim *sim, · line 191
Quoted 6 lines
id); +
intofono_sim_get_ready(struct ofono_sim *sim);include/sim.h +3
-1-void ofono_sim_set_ready (struct ofono_sim *sim); + +void ofono_sim_inserted (struct ofono_sim *sim); +void ofono_sim_removed (struct ofono_sim *sim);
Lets make these into a single function with a ofono_bool_t parameter.
include/sim.h unsigned int ofono_sim_add_ready_watch(struct ofono_sim *sim, · line 193
Quoted 2 lines
include/sim.h +2
-0+void ofono_sim_proactive_command_notify (struct ofono_sim *sim, +int length,const guint8 *pdu);
Can you send this part in a separate patch? And this belongs on a separate stk atom.
Quoted 15 lines
src/sim.c +15
-0+void ofono_sim_inserted (struct ofono_sim *sim) +{ + sim->inserted = TRUE; + +/* Perform SIM initialization according to 3GPP 31.102 Section 5.1.1.2 +* The assumption here is that if sim manager is being initialized, +* then sim commands are implemented, and the sim manager is then +* responsible for checking the PIN, reading the IMSI and signaling +* SIM ready condition. +* +* The procedure according to 31.102 is roughly: +* Read EFecc +* Read EFli and EFpl +* SIM Pin check +* Request SIM phase (only in 51.011)
src/sim.c const unsigned char *ofono_sim_get_cphs_service_table(struct ofono_sim *sim) · line 1775
Quoted 10 lines
src/sim.c +10
-0+* Read EFust +* Read EFest +* Read IMSI +* +* At this point we signal the SIM ready condition and allow +* arbitrary files to be written or read, assuming their presence +* in the EFust +*/ +sim_determine_phase (sim); +}
The only other issue here is that you have to wait for the sim atom to register before you start the initialization process.
src/sim.c const unsigned char *ofono_sim_get_cphs_service_table(struct ofono_sim *sim) · line 1804
Quoted 5 lines
src/sim.c +5
-0+void ofono_sim_proactive_command_notify (struct ofono_sim *sim, +int length,const guint8 *pdu) +{ +} +
This belongs on a separate stk atom.
Regards,
-Denis