OSDN Git Service

Prevent ConcurrentModificationException in updateAllRecognitions
authorChris Thornton <thorntonc@google.com>
Sun, 11 Jun 2017 00:31:57 +0000 (17:31 -0700)
committerChris Thornton <thorntonc@google.com>
Mon, 12 Jun 2017 04:14:53 +0000 (21:14 -0700)
commitd3178c4ed52358009d51518551325b5b0c84de67
tree1cac18f4f609d5e6516ce0dd01ca01f2ea3cc88f
parentb32fecd6e0dad258542e702144a04b3cadea6bd3
Prevent ConcurrentModificationException in updateAllRecognitions

When invoking updateAllRecognitions, if a callback binder was determined
to have died, an internal function would go and remove it from
mModelDataMap. However, updateAllRecognitions was iterating over this
map, so it would then explode. By first making a copy of the model datas
before iterating over all of them, this problem is avoided.

(As part of trying to figure out what was happening, also updated all
the method names that implicitly assumed they had a lock, and double
checked that everything with a Locked suffix is actually locked)

Bug: 62487479
Test: Use the sound trigger test app to load and start two models, force
kill the app (so the dangling binders hang around), then enable power
save (which triggers the call to updateAllRecognitions)

Change-Id: I87b9dfc1b2af5e294050b146737916ccaad882c1
services/voiceinteraction/java/com/android/server/soundtrigger/SoundTriggerHelper.java