FROMLIST: broadband-modem-mbim: preserve unlock retries for PIN1 when appropriate

If PIN1 is disabled and we have tried to enable it with a wrong PIN, a
MBIM modem would have indicated the number of remaining attempts for
PIN1 (unless PUK1 is engaged) in the response to the failed MBIM_CID_PIN
set operation.

However, a MBIM_CID_PIN query may be issued (e.g.  MMBaseSim calls
mm_iface_modem_update_lock_info()) after the MBIM_CID_PIN set operation
to query the number of remaining attempts for a PIN type. Unfortunately,
we can't specify a particular PIN type in a MBIM_CID_PIN query. The
modem may not reply with information about PIN1 if PIN1 is disabled.
When that happens, we would like to preserve our knowledge about the
number of remaining attempts for PIN1.

This patch modifies MMBroadbandModemMbim's load_unlock_retries()
operation to carry over any existing information on PIN1
from MMIfaceModem's MMUnlockRetries if the MBIM_CID_PIN query reports
something other than PIN1.

See https://lists.freedesktop.org/archives/modemmanager-devel/2017-August/005547.html

BUG=chromium:753478
TEST=Tested the following on a Chromebook with a MBIM modem:
- Enable SIM locking via the Chrome OS settings UI.
- When the UI prompts for a PIN, Enter a wrong PIN.
- Verify that the UI reports an error and shows the correct number of
  retries left for entering the PIN.
- Enter a wrong PIN again.
- Verify that the UI reports an error and shows the correct number of
  retries left for entering the PIN.

Change-Id: Ie2def5c9b8ddff976be5c1c8e087f8a181de4bf0
Reviewed-on: https://chromium-review.googlesource.com/625461
Commit-Ready: Ben Chan <benchan@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
Reviewed-by: Eric Caruso <ejcaruso@chromium.org>
1 file changed