Keymint: Use ndk_platform.

Test: N/A
Change-Id: I7e97d9d475a639cfe92c9e6b01689c9ff80d2abc
diff --git a/security/keymint/aidl/default/Android.bp b/security/keymint/aidl/default/Android.bp
index 491a2c1..79697c4 100644
--- a/security/keymint/aidl/default/Android.bp
+++ b/security/keymint/aidl/default/Android.bp
@@ -9,7 +9,7 @@
         "-Wextra",
     ],
     shared_libs: [
-        "android.hardware.security.keymint-ndk_platform",
+        "android.hardware.security.keymint-unstable-ndk_platform",
         "libbase",
         "libbinder_ndk",
         "libcppbor",
diff --git a/security/keymint/aidl/vts/functional/Android.bp b/security/keymint/aidl/vts/functional/Android.bp
index ef7adb1..c7cc380 100644
--- a/security/keymint/aidl/vts/functional/Android.bp
+++ b/security/keymint/aidl/vts/functional/Android.bp
@@ -25,13 +25,13 @@
         "VerificationTokenTest.cpp",
     ],
     shared_libs: [
-        "libbinder",
+        "libbinder_ndk",
         "libcrypto",
         "libkeymint",
         "libkeymint_support",
     ],
     static_libs: [
-        "android.hardware.security.keymint-cpp",
+        "android.hardware.security.keymint-unstable-ndk_platform",
         "libcppbor_external",
         "libkeymint_vts_test_utils",
     ],
@@ -54,13 +54,13 @@
         ".",
     ],
     shared_libs: [
-        "libbinder",
+        "libbinder_ndk",
         "libcrypto",
         "libkeymint",
         "libkeymint_support",
     ],
     static_libs: [
-        "android.hardware.security.keymint-cpp",
+        "android.hardware.security.keymint-unstable-ndk_platform",
         "libcppbor",
     ],
 }
diff --git a/security/keymint/aidl/vts/functional/KeyMintAidlTestBase.cpp b/security/keymint/aidl/vts/functional/KeyMintAidlTestBase.cpp
index ea3a329..9ba4099 100644
--- a/security/keymint/aidl/vts/functional/KeyMintAidlTestBase.cpp
+++ b/security/keymint/aidl/vts/functional/KeyMintAidlTestBase.cpp
@@ -20,11 +20,12 @@
 #include <vector>
 
 #include <android-base/logging.h>
+#include <android/binder_manager.h>
 
 #include <keymint_support/key_param_output.h>
 #include <keymint_support/keymint_utils.h>
 
-namespace android::hardware::security::keymint {
+namespace aidl::android::hardware::security::keymint {
 
 using namespace std::literals::chrono_literals;
 using std::endl;
@@ -42,19 +43,19 @@
 
 namespace test {
 
-ErrorCode KeyMintAidlTestBase::GetReturnErrorCode(Status result) {
+ErrorCode KeyMintAidlTestBase::GetReturnErrorCode(const Status& result) {
     if (result.isOk()) return ErrorCode::OK;
 
-    if (result.exceptionCode() == binder::Status::EX_SERVICE_SPECIFIC) {
-        return static_cast<ErrorCode>(result.serviceSpecificErrorCode());
+    if (result.getExceptionCode() == EX_SERVICE_SPECIFIC) {
+        return static_cast<ErrorCode>(result.getServiceSpecificError());
     }
 
     return ErrorCode::UNKNOWN_ERROR;
 }
 
-void KeyMintAidlTestBase::InitializeKeyMint(sp<IKeyMintDevice> keyMint) {
+void KeyMintAidlTestBase::InitializeKeyMint(std::shared_ptr<IKeyMintDevice> keyMint) {
     ASSERT_NE(keyMint, nullptr);
-    keymint_ = keyMint;
+    keymint_ = std::move(keyMint);
 
     KeyMintHardwareInfo info;
     ASSERT_TRUE(keymint_->getHardwareInfo(&info).isOk());
@@ -68,8 +69,12 @@
 }
 
 void KeyMintAidlTestBase::SetUp() {
-    InitializeKeyMint(
-            android::waitForDeclaredService<IKeyMintDevice>(String16(GetParam().c_str())));
+    if (AServiceManager_isDeclared(GetParam().c_str())) {
+        ::ndk::SpAIBinder binder(AServiceManager_waitForService(GetParam().c_str()));
+        InitializeKeyMint(IKeyMintDevice::fromBinder(binder));
+    } else {
+        InitializeKeyMint(nullptr);
+    }
 }
 
 ErrorCode KeyMintAidlTestBase::GenerateKey(const AuthorizationSet& key_desc,
@@ -176,7 +181,7 @@
         *key_blob = vector<uint8_t>();
     }
 
-    EXPECT_TRUE(result.isOk()) << result.serviceSpecificErrorCode() << endl;
+    EXPECT_TRUE(result.isOk()) << result.getServiceSpecificError() << endl;
     return GetReturnErrorCode(result);
 }
 
@@ -186,7 +191,7 @@
 
 ErrorCode KeyMintAidlTestBase::DeleteAllKeys() {
     Status result = keymint_->deleteAllKeys();
-    EXPECT_TRUE(result.isOk()) << result.serviceSpecificErrorCode() << endl;
+    EXPECT_TRUE(result.isOk()) << result.getServiceSpecificError() << endl;
     return GetReturnErrorCode(result);
 }
 
@@ -201,7 +206,8 @@
 
 ErrorCode KeyMintAidlTestBase::Begin(KeyPurpose purpose, const vector<uint8_t>& key_blob,
                                      const AuthorizationSet& in_params,
-                                     AuthorizationSet* out_params, sp<IKeyMintOperation>& op) {
+                                     AuthorizationSet* out_params,
+                                     std::shared_ptr<IKeyMintOperation>& op) {
     SCOPED_TRACE("Begin");
     Status result;
     BeginResult out;
@@ -326,7 +332,7 @@
         output->append(oPut.begin(), oPut.end());
     }
 
-    op_.clear();  // So dtor doesn't Abort().
+    op_.reset();
     return GetReturnErrorCode(result);
 }
 
@@ -358,7 +364,7 @@
     return result;
 }
 
-ErrorCode KeyMintAidlTestBase::Abort(const sp<IKeyMintOperation>& op) {
+ErrorCode KeyMintAidlTestBase::Abort(const std::shared_ptr<IKeyMintOperation>& op) {
     SCOPED_TRACE("Abort");
 
     EXPECT_NE(op, nullptr);
@@ -368,7 +374,7 @@
 
     Status retval = op->abort();
     EXPECT_TRUE(retval.isOk());
-    return static_cast<ErrorCode>(retval.serviceSpecificErrorCode());
+    return static_cast<ErrorCode>(retval.getServiceSpecificError());
 }
 
 ErrorCode KeyMintAidlTestBase::Abort() {
@@ -380,14 +386,14 @@
     }
 
     Status retval = op_->abort();
-    return static_cast<ErrorCode>(retval.serviceSpecificErrorCode());
+    return static_cast<ErrorCode>(retval.getServiceSpecificError());
 }
 
 void KeyMintAidlTestBase::AbortIfNeeded() {
     SCOPED_TRACE("AbortIfNeeded");
     if (op_) {
         EXPECT_EQ(ErrorCode::OK, Abort());
-        op_.clear();
+        op_.reset();
     }
 }
 
@@ -522,7 +528,7 @@
     AuthorizationSet finish_out_params;
     EXPECT_EQ(ErrorCode::OK, Finish(finish_params, message.substr(consumed), signature,
                                     &finish_out_params, &output));
-    op_.clear();
+    op_.reset();
     EXPECT_TRUE(output.empty());
 }
 
@@ -750,4 +756,4 @@
 
 }  // namespace test
 
-}  // namespace android::hardware::security::keymint
+}  // namespace aidl::android::hardware::security::keymint
diff --git a/security/keymint/aidl/vts/functional/KeyMintAidlTestBase.h b/security/keymint/aidl/vts/functional/KeyMintAidlTestBase.h
index 052736b..f73c26d 100644
--- a/security/keymint/aidl/vts/functional/KeyMintAidlTestBase.h
+++ b/security/keymint/aidl/vts/functional/KeyMintAidlTestBase.h
@@ -22,15 +22,15 @@
 #include <binder/ProcessState.h>
 #include <gtest/gtest.h>
 
-#include <android/hardware/security/keymint/ErrorCode.h>
-#include <android/hardware/security/keymint/IKeyMintDevice.h>
+#include <aidl/android/hardware/security/keymint/ErrorCode.h>
+#include <aidl/android/hardware/security/keymint/IKeyMintDevice.h>
 
 #include <keymint_support/authorization_set.h>
 
-namespace android::hardware::security::keymint::test {
+namespace aidl::android::hardware::security::keymint::test {
 
 using ::android::sp;
-using binder::Status;
+using Status = ::ndk::ScopedAStatus;
 using ::std::shared_ptr;
 using ::std::string;
 using ::std::vector;
@@ -49,12 +49,12 @@
         AbortIfNeeded();
     }
 
-    void InitializeKeyMint(sp<IKeyMintDevice> keyMint);
+    void InitializeKeyMint(std::shared_ptr<IKeyMintDevice> keyMint);
     IKeyMintDevice& keyMint() { return *keymint_; }
     uint32_t os_version() { return os_version_; }
     uint32_t os_patch_level() { return os_patch_level_; }
 
-    ErrorCode GetReturnErrorCode(Status result);
+    ErrorCode GetReturnErrorCode(const Status& result);
     ErrorCode GenerateKey(const AuthorizationSet& key_desc, vector<uint8_t>* key_blob,
                           KeyCharacteristics* key_characteristics);
 
@@ -80,7 +80,7 @@
 
     ErrorCode Begin(KeyPurpose purpose, const vector<uint8_t>& key_blob,
                     const AuthorizationSet& in_params, AuthorizationSet* out_params,
-                    sp<IKeyMintOperation>& op);
+                    std::shared_ptr<IKeyMintOperation>& op);
     ErrorCode Begin(KeyPurpose purpose, const vector<uint8_t>& key_blob,
                     const AuthorizationSet& in_params, AuthorizationSet* out_params);
     ErrorCode Begin(KeyPurpose purpose, const AuthorizationSet& in_params,
@@ -98,7 +98,7 @@
     ErrorCode Finish(string* output) { return Finish(string(), output); }
 
     ErrorCode Abort();
-    ErrorCode Abort(const sp<IKeyMintOperation>& op);
+    ErrorCode Abort(const shared_ptr<IKeyMintOperation>& op);
     void AbortIfNeeded();
 
     string ProcessMessage(const vector<uint8_t>& key_blob, KeyPurpose operation,
@@ -159,17 +159,17 @@
     vector<Digest> ValidDigests(bool withNone, bool withMD5);
 
     static vector<string> build_params() {
-        auto params = android::getAidlHalInstanceNames(IKeyMintDevice::descriptor);
+        auto params = ::android::getAidlHalInstanceNames(IKeyMintDevice::descriptor);
         return params;
     }
 
-    sp<IKeyMintOperation> op_;
+    std::shared_ptr<IKeyMintOperation> op_;
     vector<Certificate> certChain_;
     vector<uint8_t> key_blob_;
     KeyCharacteristics key_characteristics_;
 
   private:
-    sp<IKeyMintDevice> keymint_;
+    std::shared_ptr<IKeyMintDevice> keymint_;
     uint32_t os_version_;
     uint32_t os_patch_level_;
 
@@ -182,6 +182,6 @@
 #define INSTANTIATE_KEYMINT_AIDL_TEST(name)                                          \
     INSTANTIATE_TEST_SUITE_P(PerInstance, name,                                      \
                              testing::ValuesIn(KeyMintAidlTestBase::build_params()), \
-                             android::PrintInstanceNameToString)
+                             ::android::PrintInstanceNameToString)
 
-}  // namespace android::hardware::security::keymint::test
+}  // namespace aidl::android::hardware::security::keymint::test
diff --git a/security/keymint/aidl/vts/functional/KeyMintTest.cpp b/security/keymint/aidl/vts/functional/KeyMintTest.cpp
index f9423a2..6e38539 100644
--- a/security/keymint/aidl/vts/functional/KeyMintTest.cpp
+++ b/security/keymint/aidl/vts/functional/KeyMintTest.cpp
@@ -26,7 +26,7 @@
 
 #include <cutils/properties.h>
 
-#include <android/hardware/security/keymint/KeyFormat.h>
+#include <aidl/android/hardware/security/keymint/KeyFormat.h>
 
 #include <keymint_support/attestation_record.h>
 #include <keymint_support/key_param_output.h>
@@ -37,21 +37,21 @@
 static bool arm_deleteAllKeys = false;
 static bool dump_Attestations = false;
 
-using android::hardware::security::keymint::AuthorizationSet;
-using android::hardware::security::keymint::KeyCharacteristics;
-using android::hardware::security::keymint::KeyFormat;
+using aidl::android::hardware::security::keymint::AuthorizationSet;
+using aidl::android::hardware::security::keymint::KeyCharacteristics;
+using aidl::android::hardware::security::keymint::KeyFormat;
 
-namespace android::hardware::security::keymint {
+namespace aidl::android::hardware::security::keymint {
 
 bool operator==(const keymint::AuthorizationSet& a, const keymint::AuthorizationSet& b) {
     return a.size() == b.size() && std::equal(a.begin(), a.end(), b.begin());
 }
 
-}  // namespace android::hardware::security::keymint
+}  // namespace aidl::android::hardware::security::keymint
 
 namespace std {
 
-using namespace android::hardware::security::keymint;
+using namespace aidl::android::hardware::security::keymint;
 
 template <>
 struct std::equal_to<KeyCharacteristics> {
@@ -73,7 +73,7 @@
 
 }  // namespace std
 
-namespace android::hardware::security::keymint::test {
+namespace aidl::android::hardware::security::keymint::test {
 
 namespace {
 
@@ -834,7 +834,7 @@
     EXPECT_EQ(ErrorCode::INVALID_OPERATION_HANDLE, Abort());
 
     // Set to sentinel, so TearDown() doesn't try to abort again.
-    op_.clear();
+    op_.reset();
 }
 
 /*
@@ -3115,7 +3115,7 @@
     EXPECT_EQ(ErrorCode::INVALID_TAG,
               Update(update_params, "", &update_out_params, &ciphertext, &input_consumed));
 
-    op_.clear();
+    op_.reset();
 }
 
 /*
@@ -3973,7 +3973,7 @@
 
     auto params = AuthorizationSetBuilder().Padding(PaddingMode::NONE);
     constexpr size_t max_operations = 100;  // set to arbituary large number
-    sp<IKeyMintOperation> op_handles[max_operations];
+    std::shared_ptr<IKeyMintOperation> op_handles[max_operations];
     AuthorizationSet out_params;
     ErrorCode result;
     size_t i;
@@ -4040,7 +4040,7 @@
 
 INSTANTIATE_KEYMINT_AIDL_TEST(TransportLimitTest);
 
-}  // namespace android::hardware::security::keymint::test
+}  // namespace aidl::android::hardware::security::keymint::test
 
 int main(int argc, char** argv) {
     ::testing::InitGoogleTest(&argc, argv);
diff --git a/security/keymint/aidl/vts/functional/VerificationTokenTest.cpp b/security/keymint/aidl/vts/functional/VerificationTokenTest.cpp
index 6d3a34e..0b1eccd 100644
--- a/security/keymint/aidl/vts/functional/VerificationTokenTest.cpp
+++ b/security/keymint/aidl/vts/functional/VerificationTokenTest.cpp
@@ -16,7 +16,7 @@
 
 #include "KeyMintAidlTestBase.h"
 
-namespace android::hardware::security::keymint::test {
+namespace aidl::android::hardware::security::keymint::test {
 
 class VerificationTokenTest : public KeyMintAidlTestBase {
   protected:
@@ -165,4 +165,4 @@
 
 INSTANTIATE_KEYMINT_AIDL_TEST(VerificationTokenTest);
 
-}  // namespace android::hardware::security::keymint::test
+}  // namespace aidl::android::hardware::security::keymint::test
diff --git a/security/keymint/support/Android.bp b/security/keymint/support/Android.bp
index ddac92f..0cfa798 100644
--- a/security/keymint/support/Android.bp
+++ b/security/keymint/support/Android.bp
@@ -31,7 +31,7 @@
         "include",
     ],
     shared_libs: [
-        "android.hardware.security.keymint-cpp",
+        "android.hardware.security.keymint-unstable-ndk_platform",
         "libbase",
         "libcrypto",
         "libutils",
diff --git a/security/keymint/support/attestation_record.cpp b/security/keymint/support/attestation_record.cpp
index 1b07495..596b097 100644
--- a/security/keymint/support/attestation_record.cpp
+++ b/security/keymint/support/attestation_record.cpp
@@ -18,8 +18,8 @@
 
 #include <assert.h>
 
-#include <android/hardware/security/keymint/Tag.h>
-#include <android/hardware/security/keymint/TagType.h>
+#include <aidl/android/hardware/security/keymint/Tag.h>
+#include <aidl/android/hardware/security/keymint/TagType.h>
 
 #include <android-base/logging.h>
 
@@ -33,7 +33,7 @@
 
 #define AT __FILE__ ":" << __LINE__
 
-namespace android::hardware::security::keymint {
+namespace aidl::android::hardware::security::keymint {
 
 struct stack_st_ASN1_TYPE_Delete {
     void operator()(stack_st_ASN1_TYPE* p) { sk_ASN1_TYPE_free(p); }
@@ -380,4 +380,4 @@
     return ErrorCode::OK;  // KM_ERROR_OK;
 }
 
-}  // namespace android::hardware::security::keymint
+}  // namespace aidl::android::hardware::security::keymint
diff --git a/security/keymint/support/authorization_set.cpp b/security/keymint/support/authorization_set.cpp
index e2aac9a..37b6cd1 100644
--- a/security/keymint/support/authorization_set.cpp
+++ b/security/keymint/support/authorization_set.cpp
@@ -16,19 +16,13 @@
 
 #include <keymint_support/authorization_set.h>
 
-#include <assert.h>
-#include <sstream>
+#include <aidl/android/hardware/security/keymint/Algorithm.h>
+#include <aidl/android/hardware/security/keymint/BlockMode.h>
+#include <aidl/android/hardware/security/keymint/Digest.h>
+#include <aidl/android/hardware/security/keymint/KeyParameter.h>
+#include <aidl/android/hardware/security/keymint/KeyPurpose.h>
 
-#include <android-base/logging.h>
-
-#include <android/hardware/security/keymint/Algorithm.h>
-#include <android/hardware/security/keymint/BlockMode.h>
-#include <android/hardware/security/keymint/Digest.h>
-#include <android/hardware/security/keymint/KeyParameter.h>
-#include <android/hardware/security/keymint/KeyPurpose.h>
-#include <android/hardware/security/keymint/TagType.h>
-
-namespace android::hardware::security::keymint {
+namespace aidl::android::hardware::security::keymint {
 
 void AuthorizationSet::Sort() {
     std::sort(data_.begin(), data_.end());
@@ -218,7 +212,7 @@
 }
 
 AuthorizationSetBuilder& AuthorizationSetBuilder::BlockMode(
-        std::initializer_list<android::hardware::security::keymint::BlockMode> blockModes) {
+        std::initializer_list<aidl::android::hardware::security::keymint::BlockMode> blockModes) {
     for (auto mode : blockModes) {
         push_back(TAG_BLOCK_MODE, mode);
     }
@@ -240,4 +234,4 @@
     return *this;
 }
 
-}  // namespace android::hardware::security::keymint
+}  // namespace aidl::android::hardware::security::keymint
diff --git a/security/keymint/support/include/keymint_support/attestation_record.h b/security/keymint/support/include/keymint_support/attestation_record.h
index 0739569..bc76c93 100644
--- a/security/keymint/support/include/keymint_support/attestation_record.h
+++ b/security/keymint/support/include/keymint_support/attestation_record.h
@@ -16,14 +16,14 @@
 
 #pragma once
 
-#include <android/hardware/security/keymint/ErrorCode.h>
-#include <android/hardware/security/keymint/IKeyMintDevice.h>
+#include <aidl/android/hardware/security/keymint/ErrorCode.h>
+#include <aidl/android/hardware/security/keymint/IKeyMintDevice.h>
 
 #include <keymint_support/attestation_record.h>
 #include <keymint_support/authorization_set.h>
 #include <keymint_support/openssl_utils.h>
 
-namespace android::hardware::security::keymint {
+namespace aidl::android::hardware::security::keymint {
 
 class AuthorizationSet;
 
@@ -84,4 +84,4 @@
                               VerifiedBoot* verified_boot_state, bool* device_locked,
                               std::vector<uint8_t>* verified_boot_hash);
 
-}  // namespace android::hardware::security::keymint
+}  // namespace aidl::android::hardware::security::keymint
diff --git a/security/keymint/support/include/keymint_support/authorization_set.h b/security/keymint/support/include/keymint_support/authorization_set.h
index 0277200..c85f305 100644
--- a/security/keymint/support/include/keymint_support/authorization_set.h
+++ b/security/keymint/support/include/keymint_support/authorization_set.h
@@ -18,14 +18,14 @@
 
 #include <vector>
 
-#include <android/hardware/security/keymint/BlockMode.h>
-#include <android/hardware/security/keymint/Digest.h>
-#include <android/hardware/security/keymint/EcCurve.h>
-#include <android/hardware/security/keymint/PaddingMode.h>
+#include <aidl/android/hardware/security/keymint/BlockMode.h>
+#include <aidl/android/hardware/security/keymint/Digest.h>
+#include <aidl/android/hardware/security/keymint/EcCurve.h>
+#include <aidl/android/hardware/security/keymint/PaddingMode.h>
 
 #include <keymint_support/keymint_tags.h>
 
-namespace android::hardware::security::keymint {
+namespace aidl::android::hardware::security::keymint {
 
 using std::vector;
 
@@ -307,4 +307,4 @@
     }
 };
 
-}  // namespace android::hardware::security::keymint
+}  // namespace aidl::android::hardware::security::keymint
diff --git a/security/keymint/support/include/keymint_support/key_param_output.h b/security/keymint/support/include/keymint_support/key_param_output.h
index b109105..6e0e35d 100644
--- a/security/keymint/support/include/keymint_support/key_param_output.h
+++ b/security/keymint/support/include/keymint_support/key_param_output.h
@@ -19,24 +19,24 @@
 #include <iostream>
 #include <vector>
 
-#include <android/hardware/security/keymint/Algorithm.h>
-#include <android/hardware/security/keymint/BlockMode.h>
-#include <android/hardware/security/keymint/Digest.h>
-#include <android/hardware/security/keymint/EcCurve.h>
-#include <android/hardware/security/keymint/ErrorCode.h>
-#include <android/hardware/security/keymint/HardwareAuthenticatorType.h>
-#include <android/hardware/security/keymint/KeyCharacteristics.h>
-#include <android/hardware/security/keymint/KeyOrigin.h>
-#include <android/hardware/security/keymint/KeyParameter.h>
-#include <android/hardware/security/keymint/KeyPurpose.h>
-#include <android/hardware/security/keymint/PaddingMode.h>
-#include <android/hardware/security/keymint/SecurityLevel.h>
-#include <android/hardware/security/keymint/Tag.h>
-#include <android/hardware/security/keymint/TagType.h>
+#include <aidl/android/hardware/security/keymint/Algorithm.h>
+#include <aidl/android/hardware/security/keymint/BlockMode.h>
+#include <aidl/android/hardware/security/keymint/Digest.h>
+#include <aidl/android/hardware/security/keymint/EcCurve.h>
+#include <aidl/android/hardware/security/keymint/ErrorCode.h>
+#include <aidl/android/hardware/security/keymint/HardwareAuthenticatorType.h>
+#include <aidl/android/hardware/security/keymint/KeyCharacteristics.h>
+#include <aidl/android/hardware/security/keymint/KeyOrigin.h>
+#include <aidl/android/hardware/security/keymint/KeyParameter.h>
+#include <aidl/android/hardware/security/keymint/KeyPurpose.h>
+#include <aidl/android/hardware/security/keymint/PaddingMode.h>
+#include <aidl/android/hardware/security/keymint/SecurityLevel.h>
+#include <aidl/android/hardware/security/keymint/Tag.h>
+#include <aidl/android/hardware/security/keymint/TagType.h>
 
 #include "keymint_tags.h"
 
-namespace android::hardware::security::keymint {
+namespace aidl::android::hardware::security::keymint {
 
 inline ::std::ostream& operator<<(::std::ostream& os, Algorithm value) {
     return os << toString(value);
@@ -96,4 +96,4 @@
     return os << toString(tag);
 }
 
-}  // namespace android::hardware::security::keymint
+}  // namespace aidl::android::hardware::security::keymint
diff --git a/security/keymint/support/include/keymint_support/keymint_tags.h b/security/keymint/support/include/keymint_support/keymint_tags.h
index d418fec..4e3d7ff 100644
--- a/security/keymint/support/include/keymint_support/keymint_tags.h
+++ b/security/keymint/support/include/keymint_support/keymint_tags.h
@@ -16,20 +16,20 @@
 
 #pragma once
 
-#include <android/hardware/security/keymint/Algorithm.h>
-#include <android/hardware/security/keymint/BlockMode.h>
-#include <android/hardware/security/keymint/Digest.h>
-#include <android/hardware/security/keymint/EcCurve.h>
-#include <android/hardware/security/keymint/HardwareAuthenticatorType.h>
-#include <android/hardware/security/keymint/KeyOrigin.h>
-#include <android/hardware/security/keymint/KeyParameter.h>
-#include <android/hardware/security/keymint/KeyPurpose.h>
-#include <android/hardware/security/keymint/PaddingMode.h>
-#include <android/hardware/security/keymint/SecurityLevel.h>
-#include <android/hardware/security/keymint/Tag.h>
-#include <android/hardware/security/keymint/TagType.h>
+#include <aidl/android/hardware/security/keymint/Algorithm.h>
+#include <aidl/android/hardware/security/keymint/BlockMode.h>
+#include <aidl/android/hardware/security/keymint/Digest.h>
+#include <aidl/android/hardware/security/keymint/EcCurve.h>
+#include <aidl/android/hardware/security/keymint/HardwareAuthenticatorType.h>
+#include <aidl/android/hardware/security/keymint/KeyOrigin.h>
+#include <aidl/android/hardware/security/keymint/KeyParameter.h>
+#include <aidl/android/hardware/security/keymint/KeyPurpose.h>
+#include <aidl/android/hardware/security/keymint/PaddingMode.h>
+#include <aidl/android/hardware/security/keymint/SecurityLevel.h>
+#include <aidl/android/hardware/security/keymint/Tag.h>
+#include <aidl/android/hardware/security/keymint/TagType.h>
 
-namespace android::hardware::security::keymint {
+namespace aidl::android::hardware::security::keymint {
 
 constexpr TagType typeFromTag(Tag tag) {
     return static_cast<TagType>(static_cast<uint32_t>(tag) & static_cast<uint32_t>(0xf0000000));
@@ -325,4 +325,4 @@
     return accessTagValue(ttag, param);
 }
 
-}  // namespace android::hardware::security::keymint
+}  // namespace aidl::android::hardware::security::keymint
diff --git a/security/keymint/support/include/keymint_support/keymint_utils.h b/security/keymint/support/include/keymint_support/keymint_utils.h
index 878b7df..53d5b96 100644
--- a/security/keymint/support/include/keymint_support/keymint_utils.h
+++ b/security/keymint/support/include/keymint_support/keymint_utils.h
@@ -16,9 +16,9 @@
 
 #pragma once
 
-#include <android/hardware/security/keymint/HardwareAuthToken.h>
+#include <aidl/android/hardware/security/keymint/HardwareAuthToken.h>
 
-namespace android::hardware::security::keymint {
+namespace aidl::android::hardware::security::keymint {
 
 using std::vector;
 
@@ -39,4 +39,4 @@
 uint32_t getOsVersion();
 uint32_t getOsPatchlevel();
 
-}  // namespace android::hardware::security::keymint
+}  // namespace aidl::android::hardware::security::keymint
diff --git a/security/keymint/support/include/keymint_support/openssl_utils.h b/security/keymint/support/include/keymint_support/openssl_utils.h
index 0878810..9ae7e52 100644
--- a/security/keymint/support/include/keymint_support/openssl_utils.h
+++ b/security/keymint/support/include/keymint_support/openssl_utils.h
@@ -16,12 +16,12 @@
 
 #pragma once
 
-#include <android/hardware/security/keymint/Digest.h>
+#include <aidl/android/hardware/security/keymint/Digest.h>
 
 #include <openssl/evp.h>
 #include <openssl/x509.h>
 
-namespace android::hardware::security::keymint {
+namespace aidl::android::hardware::security::keymint {
 
 template <typename T, void (*F)(T*)>
 struct UniquePtrDeleter {
@@ -61,4 +61,4 @@
     return nullptr;
 }
 
-}  // namespace android::hardware::security::keymint
+}  // namespace aidl::android::hardware::security::keymint
diff --git a/security/keymint/support/key_param_output.cpp b/security/keymint/support/key_param_output.cpp
index d8e2fff..c56e035 100644
--- a/security/keymint/support/key_param_output.cpp
+++ b/security/keymint/support/key_param_output.cpp
@@ -20,7 +20,7 @@
 
 #include <keymint_support/keymint_tags.h>
 
-namespace android::hardware::security::keymint {
+namespace aidl::android::hardware::security::keymint {
 
 using ::std::endl;
 using ::std::ostream;
@@ -69,4 +69,4 @@
     return os << "UNKNOWN TAG TYPE!";
 }
 
-}  // namespace android::hardware::security::keymint
+}  // namespace aidl::android::hardware::security::keymint
diff --git a/security/keymint/support/keymint_utils.cpp b/security/keymint/support/keymint_utils.cpp
index 63606f4..e73d602 100644
--- a/security/keymint/support/keymint_utils.cpp
+++ b/security/keymint/support/keymint_utils.cpp
@@ -16,14 +16,10 @@
 
 #include <regex.h>
 
-#include <arpa/inet.h>
-
 #include <android-base/properties.h>
 #include <hardware/hw_auth_token.h>
 
-#include <keymint_support/keymint_utils.h>
-
-namespace android::hardware::security::keymint {
+namespace aidl::android::hardware::security::keymint {
 
 namespace {
 
@@ -112,4 +108,4 @@
     return getOsPatchlevel(patchlevel.c_str());
 }
 
-}  // namespace android::hardware::security::keymint
+}  // namespace aidl::android::hardware::security::keymint