There's an issue for which I'd like to hear your opinion.
ofono_sim_inserted_notify signals org.ofono.SimManager Present property true,
but PinRequired and LockedPins are known only after
__ofono_sim_recheck_pin asks them from driver.
Problem can arise at startup but I've met this especially during
hotswap i.e. when I remove and insert the same/different card.
If a driver completes query_passwd_state synchronously there's less
room for problems, but if driver has to find out the values
asynchronously the time window is longer.
I'm using an implementation of rilmodem, but even the default atmodem
driver asks password state asynchronously (AT+CPIN?).
If a client, for example triggered by the Present property change
signal, asks GetProperties during the time window then PinRequired &
LockedPins values are not updated yet.
A client can't work around Problem1, it doesn't know when after a
hotswap PinRequired becomes available. sim_pin_query_cb checks
"sim->pin_type = pin_type" before emitting PinRequired changed signal.
Works for boot when pin_type is 0 but not for card hotswap because
sim->pin_type is not reset, instead the old value is preserved.
One fix proposal to Problem2 is to reset pin_type to
OFONO_SIM_PASSWORD_INVALID in ofono_sim_inserted_notify when removed.
That requires skipping appending PinRequired in sim_get_properties()
if value is OFONO_SIM_PASSWORD_INVALID, otherwise
ofono_dbus_dict_append crashes because sim_passwd_name() didn't have a
value for OFONO_SIM_PASSWORD_INVALID.
(I would've put resetting to sim_free_main_state(), but that's called
when changing PIN fails due to wrong passwords and sim app switches
PUK lock (OFONO_SIM_STATE_LOCKED_OUT), it would reset the password
type already set as puk.)
Similar for LockedPins, but there reason is sim_pin_query_cb() doesn't
emit property change all.
Fix proposal to Problem3 is to emit a change signal sim_pin_query_cb()
if "sim->locked_pins[pin_type]" wasn't already TRUE.
Please let me know your comments and improvement ideas. I can submit
patches if you're interested.