Add abstract wrapper around IKeymasterDevice.

The "Keymaster" class provides an abstraction that hides the
underlying implementation.  It will always inherit the current
IKeymasterDevice version and extend it with additional pure virtual methods
that are used by keystore to query for meta information.  This class
will in turn have subclasses which will wrap an instance of each
different version of IKeymasterDevice that we support.

Test: CTS
Change-Id: I62420dc0a8c196bb3f19753a8f304d46a75fae0e
diff --git a/keystore/key_store_service.h b/keystore/key_store_service.h
index 0a1b8f1..0316d6d 100644
--- a/keystore/key_store_service.h
+++ b/keystore/key_store_service.h
@@ -35,10 +35,9 @@
 // binder::Status. Input parameters cannot be null unless annotated with @nullable in .aidl file.
 class KeyStoreService : public android::security::BnKeystoreService,
                         android::IBinder::DeathRecipient {
-    typedef ::android::sp<::android::hardware::keymaster::V3_0::IKeymasterDevice> km_device_t;
-
   public:
     explicit KeyStoreService(KeyStore* keyStore) : mKeyStore(keyStore), mOperationMap(this) {}
+    virtual ~KeyStoreService() = default;
 
     void binderDied(const android::wp<android::IBinder>& who);
 
@@ -217,7 +216,7 @@
      */
     bool checkAllowedOperationParams(const hidl_vec<KeyParameter>& params);
 
-    ErrorCode getOperationCharacteristics(const hidl_vec<uint8_t>& key, km_device_t* dev,
+    ErrorCode getOperationCharacteristics(const hidl_vec<uint8_t>& key, sp<Keymaster>* dev,
                                           const AuthorizationSet& params, KeyCharacteristics* out);
 
     /**
@@ -274,7 +273,7 @@
     KeyStoreServiceReturnCode upgradeKeyBlob(const android::String16& name, uid_t targetUid,
                                              const AuthorizationSet& params, Blob* blob);
 
-    ::KeyStore* mKeyStore;
+    KeyStore* mKeyStore;
     OperationMap mOperationMap;
     keystore::AuthTokenTable mAuthTokenTable;
     KeystoreKeymasterEnforcement enforcement_policy;