Test large numbers of keys in the database

Primarily to test garbage collection, but testing on a device with lots
of keys also showed some other slow operations so test those too.

Test: keystore2_test
Bug: 319563050
Change-Id: I308451992aa7cd6fd1a0fa43f0c113228ae7845d
diff --git a/keystore2/src/utils.rs b/keystore2/src/utils.rs
index 0a545f7..7e29f17 100644
--- a/keystore2/src/utils.rs
+++ b/keystore2/src/utils.rs
@@ -519,7 +519,7 @@
     result
 }
 
-fn estimate_safe_amount_to_return(
+pub(crate) fn estimate_safe_amount_to_return(
     domain: Domain,
     namespace: i64,
     key_descriptors: &[KeyDescriptor],
@@ -557,6 +557,9 @@
     items_to_return
 }
 
+/// Estimate for maximum size of a Binder response in bytes.
+pub(crate) const RESPONSE_SIZE_LIMIT: usize = 358400;
+
 /// List all key aliases for a given domain + namespace. whose alias is greater
 /// than start_past_alias (if provided).
 pub fn list_key_entries(
@@ -580,7 +583,6 @@
         start_past_alias,
     );
 
-    const RESPONSE_SIZE_LIMIT: usize = 358400;
     let safe_amount_to_return =
         estimate_safe_amount_to_return(domain, namespace, &merged_key_entries, RESPONSE_SIZE_LIMIT);
     Ok(merged_key_entries[..safe_amount_to_return].to_vec())