Fix for crash due to ConcurrentModificationException in PrintRecommendationService

We observed a crash on the DPS application's printer list screen,
triggered by the Recommendations service.
Steps to Reproduce:
On the printer panel, change a few printers to a different network,
making them unavailable on the current network. On the DPS printer list
screen, wait for a considerable amount of time (approximately 40 seconds).
As checked, a ConcurrentModificationException was observed in adb logs.
The exception is coming from the printerRemoved function in the
ServiceListener class of the PrintRecommendationService. This function
is invoked via onServiceLost from the NsdManager discovery callbacks. We
provided a small fix to handle this by creating a copy of the key set to
avoid modifying the original mVendorHashMap.

Test: Go to Settings->Connected devices->Connection preferences->
Printing->Default Print Service and once the printers get listed, remove
few printers from the network.

Google: 3629430
Change-Id: Id34300d580de58c6096fdce126a8db7521668428
Signed-off-by: Saurabh Chauhan <mopriadevteam@gmail.com>
Signed-off-by: Jackeagle <jackeagle102@gmail.com>
1 file changed