Keystore 2.0: Untangle GC from Keystore DB.

Notifying the garbage collector directly from the DB breaks the unit
test because the GC implicitly uses the global DB instance.
This moves GC notification outside of the KeystoreDB.

Also remove #[!allow(dead_code)] from database.rs.

Test: keystore2_test
Change-Id: Ia2812d47ccee05309aaa91063d0d99c853596ea1
diff --git a/keystore2/src/security_level.rs b/keystore2/src/security_level.rs
index 7f41ae8..d8787bd 100644
--- a/keystore2/src/security_level.rs
+++ b/keystore2/src/security_level.rs
@@ -16,6 +16,7 @@
 
 //! This crate implements the IKeystoreSecurityLevel interface.
 
+use crate::gc::Gc;
 use android_hardware_security_keymint::aidl::android::hardware::security::keymint::{
     Algorithm::Algorithm, HardwareAuthenticatorType::HardwareAuthenticatorType,
     IKeyMintDevice::IKeyMintDevice, KeyCreationResult::KeyCreationResult, KeyFormat::KeyFormat,
@@ -129,7 +130,7 @@
                     metadata.add(KeyMetaEntry::CreationDate(creation_date));
 
                     let mut db = db.borrow_mut();
-                    let key_id = db
+                    let (need_gc, key_id) = db
                         .store_new_key(
                             key,
                             &key_parameters,
@@ -139,6 +140,9 @@
                             &metadata,
                         )
                         .context("In store_new_key.")?;
+                    if need_gc {
+                        Gc::notify_gc();
+                    }
                     Ok(KeyDescriptor {
                         domain: Domain::KEY_ID,
                         nspace: key_id.id(),