Fixed a race when slot-to-sub mapping table is rebuilding

When updateSubscriptionInfoByIccId is called, we always clear
the slot-to-sub id map first and then rebuild it. If other threads
access this map while the rebuilding is ongoing, subscription
controller returns an empty map that leads other threads think we
don't have any valid subscription at that moment. This indeed caused
some issues such like no data connection or device issued unexpected
LTE detach request to the mobile network.

Adding a lock to protect the entire rebuilding process and the map
might be an option but actually the Telephony provider, which
also has its own lock, has dependency on this map. The reverse lock
acuisition orders can cause deadlock, which eventually leads to an
ANR.

A workaround here is that we only clear the map when one/some SIMs
are gone.

A more comprehensive refactoring for building this slot-to-sub map
will be added in future releases.

Bug: 29579544
Test: Manual + unit tests
Change-Id: Id25d1f82a04bfd1f593d496e29f2e6619e499946
Merged-In: I88992d9cc92d18f7e344b58ea49b1d3007b50b41
1 file changed