Keystore 2.0: Revisited pruning strategy

There was a bug by which we could end up spinning in an endless loop in
the case where finalized operations were still considered for pruning.
We try to check the outcome of an operation and refrain from considering
it for pruning if it is confirmed finalized and awaiting garbage
collection.

We also made a tweak to the pruning strategy, that allows clients to
cannibalize their own operations if no other slot can be found. This is
catering to the Java Keystore SPI which has no synchronous way of
aborting an operation. The CTS test actually spawns many operations that
it does not intend to finalize. It simply drops the corresponding crypto
object, which then might linger until the garbage collector decides to
clean up.

Test: Cts test passes without throwing backend busy exceptions.
Change-Id: I05ee231d22877a166107e5d02c88501d0fb6bf13
1 file changed