From 35f0f22c9b8cb9d8672c9cc5226c9037d621da7f Mon Sep 17 00:00:00 2001 From: Shawn Willden Date: Thu, 16 Jan 2020 13:21:42 -0700 Subject: [PATCH] Update vold to use KM4.1 This CL updates vold to use the Keymaster 4.1 interface, but does not yet call any of the new methods. Test: Boot the device Change-Id: I4574a2f6eead3b71d1e89488b496b734694620c7 Merged-In: I4574a2f6eead3b71d1e89488b496b734694620c7 --- Android.bp | 4 ++++ KeyStorage.cpp | 4 ++-- Keymaster.cpp | 4 ++-- Keymaster.h | 17 ++++++++++++++--- 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/Android.bp b/Android.bp index fd6ef1d..ab833ad 100644 --- a/Android.bp +++ b/Android.bp @@ -43,6 +43,7 @@ cc_defaults { shared_libs: [ "android.hardware.keymaster@3.0", "android.hardware.keymaster@4.0", + "android.hardware.keymaster@4.1", "android.hardware.boot@1.0", "libbase", "libbinder", @@ -57,6 +58,7 @@ cc_defaults { "libincfs", "libhidlbase", "libkeymaster4support", + "libkeymaster4_1support", "libkeyutils", "liblog", "liblogwrap", @@ -231,10 +233,12 @@ cc_binary { "android.hardware.keymaster@3.0", "android.hardware.keymaster@4.0", + "android.hardware.keymaster@4.1", "libhardware", "libhardware_legacy", "libhidlbase", "libkeymaster4support", + "libkeymaster4_1support", ], } diff --git a/KeyStorage.cpp b/KeyStorage.cpp index d5ac7d0..dbf190d 100644 --- a/KeyStorage.cpp +++ b/KeyStorage.cpp @@ -43,8 +43,8 @@ #include #include -#include -#include +#include +#include extern "C" { diff --git a/Keymaster.cpp b/Keymaster.cpp index aad4387..a3853f9 100644 --- a/Keymaster.cpp +++ b/Keymaster.cpp @@ -17,8 +17,8 @@ #include "Keymaster.h" #include -#include -#include +#include +#include namespace android { namespace vold { diff --git a/Keymaster.h b/Keymaster.h index 42a2b5d..7ade10d 100644 --- a/Keymaster.h +++ b/Keymaster.h @@ -24,13 +24,24 @@ #include #include -#include -#include +#include +#include namespace android { namespace vold { -namespace km = ::android::hardware::keymaster::V4_0; +namespace km { + +using namespace ::android::hardware::keymaster::V4_1; + +// Surprisingly -- to me, at least -- this is totally fine. You can re-define symbols that were +// brought in via a using directive (the "using namespace") above. In general this seems like a +// dangerous thing to rely on, but in this case its implications are simple and straightforward: +// km::ErrorCode refers to the 4.0 ErrorCode, though we pull everything else from 4.1. +using ErrorCode = ::android::hardware::keymaster::V4_0::ErrorCode; + +} // namespace km + using KmDevice = km::support::Keymaster; // C++ wrappers to the Keymaster hidl interface.