Merge changes from topic "aosp-audio-base-h"

* changes:
  audio: Add @export annotations to microphone-related enums
  Make audio*-base.h files autogenerated again
diff --git a/audio/common/all-versions/default/service/android.hardware.audio.service.rc b/audio/common/all-versions/default/service/android.hardware.audio.service.rc
index f7e1e24..45fef9a 100644
--- a/audio/common/all-versions/default/service/android.hardware.audio.service.rc
+++ b/audio/common/all-versions/default/service/android.hardware.audio.service.rc
@@ -2,7 +2,7 @@
     class hal
     user audioserver
     # media gid needed for /dev/fm (radio) and for /data/misc/media (tee)
-    group audio camera drmrpc inet media mediadrm net_bt net_bt_admin net_bw_acct wakelock
+    group audio camera drmrpc inet media mediadrm net_bt net_bt_admin net_bw_acct wakelock context_hub
     capabilities BLOCK_SUSPEND
     ioprio rt 4
     task_profiles ProcessCapacityHigh HighPerformance
diff --git a/automotive/vehicle/2.0/default/Android.bp b/automotive/vehicle/2.0/default/Android.bp
index 9a0d89d..246246c 100644
--- a/automotive/vehicle/2.0/default/Android.bp
+++ b/automotive/vehicle/2.0/default/Android.bp
@@ -88,6 +88,7 @@
     whole_static_libs: [
         "android.hardware.automotive.vehicle@2.0-emulated-user-hal-lib",
         "android.hardware.automotive.vehicle@2.0-manager-lib",
+        "libqemu_pipe",
     ],
     shared_libs: [
         "libbase",
@@ -95,7 +96,6 @@
         "libprotobuf-cpp-lite",
     ],
     static_libs: [
-        "libqemu_pipe",
         "android.hardware.automotive.vehicle@2.0-libproto-native",
     ],
 }
@@ -211,6 +211,5 @@
         "android.hardware.automotive.vehicle@2.0-manager-lib",
         "android.hardware.automotive.vehicle@2.0-default-impl-lib",
         "android.hardware.automotive.vehicle@2.0-libproto-native",
-        "libqemu_pipe",
     ],
 }
diff --git a/automotive/vehicle/2.0/default/common/src/VehicleHalManager.cpp b/automotive/vehicle/2.0/default/common/src/VehicleHalManager.cpp
index b09e9bf..dc5d3d3 100644
--- a/automotive/vehicle/2.0/default/common/src/VehicleHalManager.cpp
+++ b/automotive/vehicle/2.0/default/common/src/VehicleHalManager.cpp
@@ -78,6 +78,7 @@
         } else {
             ALOGW("Requested config for undefined property: 0x%x", prop);
             _hidl_cb(StatusCode::INVALID_ARG, hidl_vec<VehiclePropConfig>());
+            return Void();
         }
     }
 
diff --git a/automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultConfig.h b/automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultConfig.h
index 16c33b9..cf18404 100644
--- a/automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultConfig.h
+++ b/automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultConfig.h
@@ -266,6 +266,20 @@
          .initialValue = {.stringValue = "Toy Vehicle"}},
         {.config =
                  {
+                         .prop = toInt(VehicleProperty::INFO_MODEL),
+                         .access = VehiclePropertyAccess::READ,
+                         .changeMode = VehiclePropertyChangeMode::STATIC,
+                 },
+         .initialValue = {.stringValue = "Speedy Model"}},
+        {.config =
+                 {
+                         .prop = toInt(VehicleProperty::INFO_MODEL_YEAR),
+                         .access = VehiclePropertyAccess::READ,
+                         .changeMode = VehiclePropertyChangeMode::STATIC,
+                 },
+         .initialValue = {.int32Values = {2020}}},
+        {.config =
+                 {
                          .prop = toInt(VehicleProperty::INFO_EXTERIOR_DIMENSIONS),
                          .access = VehiclePropertyAccess::READ,
                          .changeMode = VehiclePropertyChangeMode::STATIC,
@@ -674,6 +688,12 @@
                          .prop = toInt(VehicleProperty::GEAR_SELECTION),
                          .access = VehiclePropertyAccess::READ,
                          .changeMode = VehiclePropertyChangeMode::ON_CHANGE,
+                         .configArray = {(int)VehicleGear::GEAR_PARK,
+                                         (int)VehicleGear::GEAR_NEUTRAL,
+                                         (int)VehicleGear::GEAR_REVERSE,
+                                         (int)VehicleGear::GEAR_DRIVE, (int)VehicleGear::GEAR_1,
+                                         (int)VehicleGear::GEAR_2, (int)VehicleGear::GEAR_3,
+                                         (int)VehicleGear::GEAR_4, (int)VehicleGear::GEAR_5},
                  },
          .initialValue = {.int32Values = {toInt(VehicleGear::GEAR_PARK)}}},
 
diff --git a/automotive/vehicle/2.0/utils/UserHalHelper.cpp b/automotive/vehicle/2.0/utils/UserHalHelper.cpp
index fcfe4bf..abf59b7 100644
--- a/automotive/vehicle/2.0/utils/UserHalHelper.cpp
+++ b/automotive/vehicle/2.0/utils/UserHalHelper.cpp
@@ -141,11 +141,6 @@
 template <typename T>
 Result<T> verifyAndCast(int32_t value) {
     T castValue = static_cast<T>(value);
-    const auto iter = hidl_enum_range<T>();
-    if (castValue < *iter.begin() || castValue > *std::prev(iter.end())) {
-        return Error() << "Value " << value << " not in range [" << toString(*iter.begin()) << ", "
-                       << toString(*std::prev(iter.end())) << "]";
-    }
     for (const auto& v : hidl_enum_range<T>()) {
         if (castValue == v) {
             return castValue;
diff --git a/compatibility_matrices/compatibility_matrix.current.xml b/compatibility_matrices/compatibility_matrix.current.xml
index 1957f8c..e9df02f 100644
--- a/compatibility_matrices/compatibility_matrix.current.xml
+++ b/compatibility_matrices/compatibility_matrix.current.xml
@@ -299,7 +299,7 @@
         </interface>
     </hal>
     <hal format="aidl" optional="true">
-        <name>android.hardware.keymint</name>
+        <name>android.hardware.security.keymint</name>
         <interface>
             <name>IKeyMintDevice</name>
             <instance>default</instance>
diff --git a/drm/1.0/vts/functional/AndroidTest.xml b/drm/1.0/vts/functional/AndroidTest.xml
index 92ea7e4..02c51cc 100644
--- a/drm/1.0/vts/functional/AndroidTest.xml
+++ b/drm/1.0/vts/functional/AndroidTest.xml
@@ -16,6 +16,7 @@
 <configuration description="Runs VtsHalDrmV1_0TargetTest.">
     <option name="test-suite-tag" value="apct" />
     <option name="test-suite-tag" value="apct-native" />
+    <option name="not-shardable" value="true" />
 
     <target_preparer class="com.android.tradefed.targetprep.RootTargetPreparer"/>
 
diff --git a/drm/1.1/vts/functional/AndroidTest.xml b/drm/1.1/vts/functional/AndroidTest.xml
index 24eeb72..4757d4a 100644
--- a/drm/1.1/vts/functional/AndroidTest.xml
+++ b/drm/1.1/vts/functional/AndroidTest.xml
@@ -16,6 +16,7 @@
 <configuration description="Runs VtsHalDrmV1_1TargetTest.">
     <option name="test-suite-tag" value="apct" />
     <option name="test-suite-tag" value="apct-native" />
+    <option name="not-shardable" value="true" />
 
     <target_preparer class="com.android.tradefed.targetprep.RootTargetPreparer"/>
 
diff --git a/drm/1.2/vts/functional/AndroidTest.xml b/drm/1.2/vts/functional/AndroidTest.xml
index 3285c37..106ad33 100644
--- a/drm/1.2/vts/functional/AndroidTest.xml
+++ b/drm/1.2/vts/functional/AndroidTest.xml
@@ -16,6 +16,7 @@
 <configuration description="Runs VtsHalDrmV1_2TargetTest.">
     <option name="test-suite-tag" value="apct" />
     <option name="test-suite-tag" value="apct-native" />
+    <option name="not-shardable" value="true" />
 
     <target_preparer class="com.android.tradefed.targetprep.RootTargetPreparer"/>
 
diff --git a/drm/1.3/vts/functional/AndroidTest.xml b/drm/1.3/vts/functional/AndroidTest.xml
index 9cc8e0c..4ec5c70 100644
--- a/drm/1.3/vts/functional/AndroidTest.xml
+++ b/drm/1.3/vts/functional/AndroidTest.xml
@@ -16,6 +16,7 @@
 <configuration description="Runs VtsHalDrmV1_3TargetTest.">
     <option name="test-suite-tag" value="apct" />
     <option name="test-suite-tag" value="apct-native" />
+    <option name="not-shardable" value="true" />
 
     <target_preparer class="com.android.tradefed.targetprep.RootTargetPreparer"/>
 
diff --git a/gnss/2.1/vts/functional/gnss_hal_test_cases.cpp b/gnss/2.1/vts/functional/gnss_hal_test_cases.cpp
index 3103df6..2902809 100644
--- a/gnss/2.1/vts/functional/gnss_hal_test_cases.cpp
+++ b/gnss/2.1/vts/functional/gnss_hal_test_cases.cpp
@@ -372,6 +372,12 @@
  * formerly strongest satellite
  */
 TEST_P(GnssHalTest, BlacklistIndividualSatellites) {
+    if (!(gnss_cb_->last_capabilities_ & IGnssCallback_2_1::Capabilities::SATELLITE_BLACKLIST)) {
+        ALOGI("Test BlacklistIndividualSatellites skipped. SATELLITE_BLACKLIST capability not "
+              "supported.");
+        return;
+    }
+
     const int kLocationsToAwait = 3;
     const int kRetriesToUnBlacklist = 10;
 
@@ -513,6 +519,12 @@
  * 4a & b) Clean up by turning off location, and send in empty blacklist.
  */
 TEST_P(GnssHalTest, BlacklistConstellationLocationOff) {
+    if (!(gnss_cb_->last_capabilities_ & IGnssCallback_2_1::Capabilities::SATELLITE_BLACKLIST)) {
+        ALOGI("Test BlacklistConstellationLocationOff skipped. SATELLITE_BLACKLIST capability not "
+              "supported.");
+        return;
+    }
+
     const int kLocationsToAwait = 3;
     const int kGnssSvInfoListTimeout = 2;
 
@@ -589,6 +601,12 @@
  * 4a & b) Clean up by turning off location, and send in empty blacklist.
  */
 TEST_P(GnssHalTest, BlacklistConstellationLocationOn) {
+    if (!(gnss_cb_->last_capabilities_ & IGnssCallback_2_1::Capabilities::SATELLITE_BLACKLIST)) {
+        ALOGI("Test BlacklistConstellationLocationOn skipped. SATELLITE_BLACKLIST capability not "
+              "supported.");
+        return;
+    }
+
     const int kLocationsToAwait = 3;
     const int kGnssSvInfoListTimeout = 2;
 
diff --git a/graphics/composer/2.1/default/Android.bp b/graphics/composer/2.1/default/Android.bp
index 533687b..a367457 100644
--- a/graphics/composer/2.1/default/Android.bp
+++ b/graphics/composer/2.1/default/Android.bp
@@ -1,31 +1,3 @@
-cc_library_shared {
-    name: "android.hardware.graphics.composer@2.1-impl",
-    defaults: ["hidl_defaults"],
-    vendor: true,
-    relative_install_path: "hw",
-    srcs: ["passthrough.cpp"],
-    header_libs: [
-        "android.hardware.graphics.composer@2.1-passthrough",
-    ],
-    shared_libs: [
-        "android.hardware.graphics.composer@2.1",
-        "android.hardware.graphics.composer@2.1-resources",
-        "libbase",
-        "libcutils",
-        "libfmq",
-        "libhardware",
-        "libhidlbase",
-        "liblog",
-        "libsync",
-        "libutils",
-        "libhwc2on1adapter",
-        "libhwc2onfbadapter",
-    ],
-    cflags: [
-        "-DLOG_TAG=\"ComposerHal\""
-    ],
-}
-
 cc_binary {
     name: "android.hardware.graphics.composer@2.1-service",
     defaults: ["hidl_defaults"],
@@ -33,10 +5,20 @@
     relative_install_path: "hw",
     srcs: ["service.cpp"],
     init_rc: ["android.hardware.graphics.composer@2.1-service.rc"],
+    header_libs: [
+        "android.hardware.graphics.composer@2.1-passthrough",
+    ],
     shared_libs: [
         "android.hardware.graphics.composer@2.1",
+        "android.hardware.graphics.composer@2.1-resources",
+        "libbase",
         "libbinder",
+        "libcutils",
+        "libfmq",
+        "libhardware",
         "libhidlbase",
+        "libhwc2on1adapter",
+        "libhwc2onfbadapter",
         "liblog",
         "libsync",
         "libutils",
diff --git a/graphics/composer/2.1/default/passthrough.cpp b/graphics/composer/2.1/default/passthrough.cpp
deleted file mode 100644
index ef7ed7c..0000000
--- a/graphics/composer/2.1/default/passthrough.cpp
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <android/hardware/graphics/composer/2.1/IComposer.h>
-#include <composer-passthrough/2.1/HwcLoader.h>
-
-using android::hardware::graphics::composer::V2_1::IComposer;
-using android::hardware::graphics::composer::V2_1::passthrough::HwcLoader;
-
-extern "C" IComposer* HIDL_FETCH_IComposer(const char* /* name */) {
-    return HwcLoader::load();
-}
diff --git a/graphics/composer/2.1/default/service.cpp b/graphics/composer/2.1/default/service.cpp
index 82a33f6..1276d2d 100644
--- a/graphics/composer/2.1/default/service.cpp
+++ b/graphics/composer/2.1/default/service.cpp
@@ -21,10 +21,11 @@
 #include <android/hardware/graphics/composer/2.1/IComposer.h>
 
 #include <binder/ProcessState.h>
+#include <composer-passthrough/2.1/HwcLoader.h>
 #include <hidl/LegacySupport.h>
 
 using android::hardware::graphics::composer::V2_1::IComposer;
-using android::hardware::defaultPassthroughServiceImplementation;
+using android::hardware::graphics::composer::V2_1::passthrough::HwcLoader;
 
 int main() {
     // the conventional HAL might start binder services
@@ -40,5 +41,19 @@
         ALOGE("Couldn't set SCHED_FIFO: %d", errno);
     }
 
-    return defaultPassthroughServiceImplementation<IComposer>(4);
+    android::hardware::configureRpcThreadpool(4, true /* will join */);
+
+    android::sp<IComposer> composer = HwcLoader::load();
+    if (composer == nullptr) {
+        return 1;
+    }
+    if (composer->registerAsService() != android::NO_ERROR) {
+        ALOGE("failed to register service");
+        return 1;
+    }
+
+    android::hardware::joinRpcThreadpool();
+
+    ALOGE("service is terminating");
+    return 1;
 }
diff --git a/keymaster/4.0/vts/functional/VerificationTokenTest.cpp b/keymaster/4.0/vts/functional/VerificationTokenTest.cpp
index bab1439..4f0a7a3 100644
--- a/keymaster/4.0/vts/functional/VerificationTokenTest.cpp
+++ b/keymaster/4.0/vts/functional/VerificationTokenTest.cpp
@@ -111,19 +111,19 @@
 
     EXPECT_GE(host_time_delta, time_to_sleep)
         << "We slept for " << time_to_sleep << " ms, the clock must have advanced by that much";
-    EXPECT_LE(host_time_delta, time_to_sleep + 20)
+    EXPECT_LE(host_time_delta, time_to_sleep + 100)
         << "The verifyAuthorization call took " << (host_time_delta - time_to_sleep)
         << " ms?  That's awful!";
 
     auto km_time_delta = result2.token.timestamp - result1.token.timestamp;
 
     // If not too much else is going on on the system, the time delta should be quite close.  Allow
-    // 2 ms of slop just to avoid test flakiness.
+    // 20 ms of slop just to avoid test flakiness.
     //
     // TODO(swillden): see if we can output values so they can be gathered across many runs and
     // report if times aren't nearly always <1ms apart.
-    EXPECT_LE(host_time_delta, km_time_delta + 2);
-    EXPECT_LE(km_time_delta, host_time_delta + 2);
+    EXPECT_LE(host_time_delta, km_time_delta + 20);
+    EXPECT_LE(km_time_delta, host_time_delta + 20);
     ASSERT_EQ(result1.token.mac.size(), result2.token.mac.size());
     ASSERT_NE(0,
               memcmp(result1.token.mac.data(), result2.token.mac.data(), result1.token.mac.size()));
@@ -172,14 +172,14 @@
 
     EXPECT_GE(host_time_delta, time_to_sleep)
             << "We slept for " << time_to_sleep << " ms, the clock must have advanced by that much";
-    EXPECT_LE(host_time_delta, time_to_sleep + 20)
+    EXPECT_LE(host_time_delta, time_to_sleep + 100)
             << "The verifyAuthorization call took " << (host_time_delta - time_to_sleep)
             << " ms?  That's awful!";
 
     auto km_time_delta = result2.token.timestamp - result1.token.timestamp;
 
-    EXPECT_LE(host_time_delta, km_time_delta + 2);
-    EXPECT_LE(km_time_delta, host_time_delta + 2);
+    EXPECT_LE(host_time_delta, km_time_delta + 20);
+    EXPECT_LE(km_time_delta, host_time_delta + 20);
     ASSERT_EQ(result1.token.mac.size(), result2.token.mac.size());
     ASSERT_NE(0,
               memcmp(result1.token.mac.data(), result2.token.mac.data(), result1.token.mac.size()));
diff --git a/keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/IKeyMintDevice.aidl b/keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/IKeyMintDevice.aidl
deleted file mode 100644
index 1616622..0000000
--- a/keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/IKeyMintDevice.aidl
+++ /dev/null
@@ -1,33 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE.                          //
-///////////////////////////////////////////////////////////////////////////////
-
-// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
-// edit this file. It looks like you are doing that because you have modified
-// an AIDL interface in a backward-incompatible way, e.g., deleting a function
-// from an interface or a field from a parcelable and it broke the build. That
-// breakage is intended.
-//
-// You must not make a backward incompatible changes to the AIDL files built
-// with the aidl_interface module type with versions property set. The module
-// type is used to build AIDL files in a way that they can be used across
-// independently updatable components of the system. If a device is shipped
-// with such a backward incompatible change, it has a high risk of breaking
-// later when a module using the interface is updated, e.g., Mainline modules.
-
-package android.hardware.keymint;
-@VintfStability
-interface IKeyMintDevice {
-  android.hardware.keymint.KeyMintHardwareInfo getHardwareInfo();
-  android.hardware.keymint.VerificationToken verifyAuthorization(in long challenge, in android.hardware.keymint.HardwareAuthToken token);
-  void addRngEntropy(in byte[] data);
-  void generateKey(in android.hardware.keymint.KeyParameter[] keyParams, out android.hardware.keymint.ByteArray generatedKeyBlob, out android.hardware.keymint.KeyCharacteristics generatedKeyCharacteristics, out android.hardware.keymint.Certificate[] outCertChain);
-  void importKey(in android.hardware.keymint.KeyParameter[] inKeyParams, in android.hardware.keymint.KeyFormat inKeyFormat, in byte[] inKeyData, out android.hardware.keymint.ByteArray outImportedKeyBlob, out android.hardware.keymint.KeyCharacteristics outImportedKeyCharacteristics, out android.hardware.keymint.Certificate[] outCertChain);
-  void importWrappedKey(in byte[] inWrappedKeyData, in byte[] inWrappingKeyBlob, in byte[] inMaskingKey, in android.hardware.keymint.KeyParameter[] inUnwrappingParams, in long inPasswordSid, in long inBiometricSid, out android.hardware.keymint.ByteArray outImportedKeyBlob, out android.hardware.keymint.KeyCharacteristics outImportedKeyCharacteristics);
-  byte[] upgradeKey(in byte[] inKeyBlobToUpgrade, in android.hardware.keymint.KeyParameter[] inUpgradeParams);
-  void deleteKey(in byte[] inKeyBlob);
-  void deleteAllKeys();
-  void destroyAttestationIds();
-  android.hardware.keymint.BeginResult begin(in android.hardware.keymint.KeyPurpose inPurpose, in byte[] inKeyBlob, in android.hardware.keymint.KeyParameter[] inParams, in android.hardware.keymint.HardwareAuthToken inAuthToken);
-  const int AUTH_TOKEN_MAC_LENGTH = 32;
-}
diff --git a/keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/IKeyMintOperation.aidl b/keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/IKeyMintOperation.aidl
deleted file mode 100644
index 5327345..0000000
--- a/keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/IKeyMintOperation.aidl
+++ /dev/null
@@ -1,24 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE.                          //
-///////////////////////////////////////////////////////////////////////////////
-
-// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
-// edit this file. It looks like you are doing that because you have modified
-// an AIDL interface in a backward-incompatible way, e.g., deleting a function
-// from an interface or a field from a parcelable and it broke the build. That
-// breakage is intended.
-//
-// You must not make a backward incompatible changes to the AIDL files built
-// with the aidl_interface module type with versions property set. The module
-// type is used to build AIDL files in a way that they can be used across
-// independently updatable components of the system. If a device is shipped
-// with such a backward incompatible change, it has a high risk of breaking
-// later when a module using the interface is updated, e.g., Mainline modules.
-
-package android.hardware.keymint;
-@VintfStability
-interface IKeyMintOperation {
-  int update(in @nullable android.hardware.keymint.KeyParameterArray inParams, in @nullable byte[] input, in @nullable android.hardware.keymint.HardwareAuthToken inAuthToken, in @nullable android.hardware.keymint.VerificationToken inVerificationToken, out @nullable android.hardware.keymint.KeyParameterArray outParams, out @nullable android.hardware.keymint.ByteArray output);
-  byte[] finish(in @nullable android.hardware.keymint.KeyParameterArray inParams, in @nullable byte[] input, in @nullable byte[] inSignature, in @nullable android.hardware.keymint.HardwareAuthToken authToken, in @nullable android.hardware.keymint.VerificationToken inVerificationToken, out @nullable android.hardware.keymint.KeyParameterArray outParams);
-  void abort();
-}
diff --git a/keymint/aidl/default/Android.bp b/keymint/aidl/default/Android.bp
deleted file mode 100644
index 539ca47..0000000
--- a/keymint/aidl/default/Android.bp
+++ /dev/null
@@ -1,26 +0,0 @@
-cc_binary {
-    name: "android.hardware.keymint@1.0-service",
-    relative_install_path: "hw",
-    init_rc: ["android.hardware.keymint@1.0-service.rc"],
-    vintf_fragments: ["android.hardware.keymint@1.0-service.xml"],
-    vendor: true,
-    cflags: [
-        "-Wall",
-        "-Wextra",
-    ],
-    shared_libs: [
-        "android.hardware.keymint-ndk_platform",
-        "libbase",
-        "libbinder_ndk",
-        "libcppbor",
-        "libcrypto",
-        "liblog",
-        "libkeymaster_portable",
-        "libkeymint1",
-        "libpuresoftkeymasterdevice",
-        "libutils",
-    ],
-    srcs: [
-        "service.cpp",
-    ],
-}
diff --git a/keymint/aidl/default/android.hardware.keymint@1.0-service.rc b/keymint/aidl/default/android.hardware.keymint@1.0-service.rc
deleted file mode 100644
index 92dce88..0000000
--- a/keymint/aidl/default/android.hardware.keymint@1.0-service.rc
+++ /dev/null
@@ -1,3 +0,0 @@
-service vendor.keymint-default /vendor/bin/hw/android.hardware.keymint@1.0-service
-    class early_hal
-    user nobody
diff --git a/keymint/aidl/Android.bp b/security/keymint/aidl/Android.bp
similarity index 76%
rename from keymint/aidl/Android.bp
rename to security/keymint/aidl/Android.bp
index 0dae527..b5adac9 100644
--- a/keymint/aidl/Android.bp
+++ b/security/keymint/aidl/Android.bp
@@ -1,8 +1,8 @@
 aidl_interface {
-    name: "android.hardware.keymint",
+    name: "android.hardware.security.keymint",
     vendor_available: true,
     srcs: [
-        "android/hardware/keymint/*.aidl",
+        "android/hardware/security/keymint/*.aidl",
     ],
     stability: "vintf",
     backend: {
diff --git a/keymint/aidl/OWNERS b/security/keymint/aidl/OWNERS
similarity index 100%
rename from keymint/aidl/OWNERS
rename to security/keymint/aidl/OWNERS
diff --git a/keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/Algorithm.aidl b/security/keymint/aidl/aidl_api/android.hardware.security.keymint/current/android/hardware/security/keymint/Algorithm.aidl
similarity index 95%
rename from keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/Algorithm.aidl
rename to security/keymint/aidl/aidl_api/android.hardware.security.keymint/current/android/hardware/security/keymint/Algorithm.aidl
index f51a412..46e0ae0 100644
--- a/keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/Algorithm.aidl
+++ b/security/keymint/aidl/aidl_api/android.hardware.security.keymint/current/android/hardware/security/keymint/Algorithm.aidl
@@ -15,7 +15,7 @@
 // with such a backward incompatible change, it has a high risk of breaking
 // later when a module using the interface is updated, e.g., Mainline modules.
 
-package android.hardware.keymint;
+package android.hardware.security.keymint;
 @Backing(type="int") @VintfStability
 enum Algorithm {
   RSA = 1,
diff --git a/keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/BeginResult.aidl b/security/keymint/aidl/aidl_api/android.hardware.security.keymint/current/android/hardware/security/keymint/BeginResult.aidl
similarity index 86%
rename from keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/BeginResult.aidl
rename to security/keymint/aidl/aidl_api/android.hardware.security.keymint/current/android/hardware/security/keymint/BeginResult.aidl
index 2f56be6..ed96485 100644
--- a/keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/BeginResult.aidl
+++ b/security/keymint/aidl/aidl_api/android.hardware.security.keymint/current/android/hardware/security/keymint/BeginResult.aidl
@@ -15,10 +15,10 @@
 // with such a backward incompatible change, it has a high risk of breaking
 // later when a module using the interface is updated, e.g., Mainline modules.
 
-package android.hardware.keymint;
+package android.hardware.security.keymint;
 @VintfStability
 parcelable BeginResult {
   long challenge;
-  android.hardware.keymint.KeyParameter[] params;
-  android.hardware.keymint.IKeyMintOperation operation;
+  android.hardware.security.keymint.KeyParameter[] params;
+  android.hardware.security.keymint.IKeyMintOperation operation;
 }
diff --git a/keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/BlockMode.aidl b/security/keymint/aidl/aidl_api/android.hardware.security.keymint/current/android/hardware/security/keymint/BlockMode.aidl
similarity index 95%
rename from keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/BlockMode.aidl
rename to security/keymint/aidl/aidl_api/android.hardware.security.keymint/current/android/hardware/security/keymint/BlockMode.aidl
index 94de930..dddc9d8 100644
--- a/keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/BlockMode.aidl
+++ b/security/keymint/aidl/aidl_api/android.hardware.security.keymint/current/android/hardware/security/keymint/BlockMode.aidl
@@ -15,7 +15,7 @@
 // with such a backward incompatible change, it has a high risk of breaking
 // later when a module using the interface is updated, e.g., Mainline modules.
 
-package android.hardware.keymint;
+package android.hardware.security.keymint;
 @Backing(type="int") @VintfStability
 enum BlockMode {
   ECB = 1,
diff --git a/keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/ByteArray.aidl b/security/keymint/aidl/aidl_api/android.hardware.security.keymint/current/android/hardware/security/keymint/ByteArray.aidl
similarity index 95%
rename from keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/ByteArray.aidl
rename to security/keymint/aidl/aidl_api/android.hardware.security.keymint/current/android/hardware/security/keymint/ByteArray.aidl
index 2dc22a9..3d18a26 100644
--- a/keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/ByteArray.aidl
+++ b/security/keymint/aidl/aidl_api/android.hardware.security.keymint/current/android/hardware/security/keymint/ByteArray.aidl
@@ -15,7 +15,7 @@
 // with such a backward incompatible change, it has a high risk of breaking
 // later when a module using the interface is updated, e.g., Mainline modules.
 
-package android.hardware.keymint;
+package android.hardware.security.keymint;
 @VintfStability
 parcelable ByteArray {
   byte[] data;
diff --git a/keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/Certificate.aidl b/security/keymint/aidl/aidl_api/android.hardware.security.keymint/current/android/hardware/security/keymint/Certificate.aidl
similarity index 95%
rename from keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/Certificate.aidl
rename to security/keymint/aidl/aidl_api/android.hardware.security.keymint/current/android/hardware/security/keymint/Certificate.aidl
index ca55054..9e0f8dc 100644
--- a/keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/Certificate.aidl
+++ b/security/keymint/aidl/aidl_api/android.hardware.security.keymint/current/android/hardware/security/keymint/Certificate.aidl
@@ -15,7 +15,7 @@
 // with such a backward incompatible change, it has a high risk of breaking
 // later when a module using the interface is updated, e.g., Mainline modules.
 
-package android.hardware.keymint;
+package android.hardware.security.keymint;
 @VintfStability
 parcelable Certificate {
   byte[] encodedCertificate;
diff --git a/keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/Digest.aidl b/security/keymint/aidl/aidl_api/android.hardware.security.keymint/current/android/hardware/security/keymint/Digest.aidl
similarity index 96%
rename from keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/Digest.aidl
rename to security/keymint/aidl/aidl_api/android.hardware.security.keymint/current/android/hardware/security/keymint/Digest.aidl
index cc4d2fd..8fc4d42 100644
--- a/keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/Digest.aidl
+++ b/security/keymint/aidl/aidl_api/android.hardware.security.keymint/current/android/hardware/security/keymint/Digest.aidl
@@ -15,7 +15,7 @@
 // with such a backward incompatible change, it has a high risk of breaking
 // later when a module using the interface is updated, e.g., Mainline modules.
 
-package android.hardware.keymint;
+package android.hardware.security.keymint;
 @Backing(type="int") @VintfStability
 enum Digest {
   NONE = 0,
diff --git a/keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/EcCurve.aidl b/security/keymint/aidl/aidl_api/android.hardware.security.keymint/current/android/hardware/security/keymint/EcCurve.aidl
similarity index 95%
rename from keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/EcCurve.aidl
rename to security/keymint/aidl/aidl_api/android.hardware.security.keymint/current/android/hardware/security/keymint/EcCurve.aidl
index 4e446ad..7c3f2f3 100644
--- a/keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/EcCurve.aidl
+++ b/security/keymint/aidl/aidl_api/android.hardware.security.keymint/current/android/hardware/security/keymint/EcCurve.aidl
@@ -15,7 +15,7 @@
 // with such a backward incompatible change, it has a high risk of breaking
 // later when a module using the interface is updated, e.g., Mainline modules.
 
-package android.hardware.keymint;
+package android.hardware.security.keymint;
 @Backing(type="int") @VintfStability
 enum EcCurve {
   P_224 = 0,
diff --git a/keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/ErrorCode.aidl b/security/keymint/aidl/aidl_api/android.hardware.security.keymint/current/android/hardware/security/keymint/ErrorCode.aidl
similarity index 98%
rename from keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/ErrorCode.aidl
rename to security/keymint/aidl/aidl_api/android.hardware.security.keymint/current/android/hardware/security/keymint/ErrorCode.aidl
index 2679243..cdcb08d 100644
--- a/keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/ErrorCode.aidl
+++ b/security/keymint/aidl/aidl_api/android.hardware.security.keymint/current/android/hardware/security/keymint/ErrorCode.aidl
@@ -15,7 +15,7 @@
 // with such a backward incompatible change, it has a high risk of breaking
 // later when a module using the interface is updated, e.g., Mainline modules.
 
-package android.hardware.keymint;
+package android.hardware.security.keymint;
 @Backing(type="int") @VintfStability
 enum ErrorCode {
   OK = 0,
diff --git a/keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/HardwareAuthToken.aidl b/security/keymint/aidl/aidl_api/android.hardware.security.keymint/current/android/hardware/security/keymint/HardwareAuthToken.aidl
similarity index 86%
rename from keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/HardwareAuthToken.aidl
rename to security/keymint/aidl/aidl_api/android.hardware.security.keymint/current/android/hardware/security/keymint/HardwareAuthToken.aidl
index 1f5f8e9..9ea24f5 100644
--- a/keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/HardwareAuthToken.aidl
+++ b/security/keymint/aidl/aidl_api/android.hardware.security.keymint/current/android/hardware/security/keymint/HardwareAuthToken.aidl
@@ -15,13 +15,13 @@
 // with such a backward incompatible change, it has a high risk of breaking
 // later when a module using the interface is updated, e.g., Mainline modules.
 
-package android.hardware.keymint;
+package android.hardware.security.keymint;
 @VintfStability
 parcelable HardwareAuthToken {
   long challenge;
   long userId;
   long authenticatorId;
-  android.hardware.keymint.HardwareAuthenticatorType authenticatorType;
-  android.hardware.keymint.Timestamp timestamp;
+  android.hardware.security.keymint.HardwareAuthenticatorType authenticatorType;
+  android.hardware.security.keymint.Timestamp timestamp;
   byte[] mac;
 }
diff --git a/keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/HardwareAuthenticatorType.aidl b/security/keymint/aidl/aidl_api/android.hardware.security.keymint/current/android/hardware/security/keymint/HardwareAuthenticatorType.aidl
similarity index 96%
rename from keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/HardwareAuthenticatorType.aidl
rename to security/keymint/aidl/aidl_api/android.hardware.security.keymint/current/android/hardware/security/keymint/HardwareAuthenticatorType.aidl
index 95ec5c5..aef5ee0 100644
--- a/keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/HardwareAuthenticatorType.aidl
+++ b/security/keymint/aidl/aidl_api/android.hardware.security.keymint/current/android/hardware/security/keymint/HardwareAuthenticatorType.aidl
@@ -15,7 +15,7 @@
 // with such a backward incompatible change, it has a high risk of breaking
 // later when a module using the interface is updated, e.g., Mainline modules.
 
-package android.hardware.keymint;
+package android.hardware.security.keymint;
 @Backing(type="int") @VintfStability
 enum HardwareAuthenticatorType {
   NONE = 0,
diff --git a/security/keymint/aidl/aidl_api/android.hardware.security.keymint/current/android/hardware/security/keymint/IKeyMintDevice.aidl b/security/keymint/aidl/aidl_api/android.hardware.security.keymint/current/android/hardware/security/keymint/IKeyMintDevice.aidl
new file mode 100644
index 0000000..3d08cfe
--- /dev/null
+++ b/security/keymint/aidl/aidl_api/android.hardware.security.keymint/current/android/hardware/security/keymint/IKeyMintDevice.aidl
@@ -0,0 +1,33 @@
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE.                          //
+///////////////////////////////////////////////////////////////////////////////
+
+// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
+// edit this file. It looks like you are doing that because you have modified
+// an AIDL interface in a backward-incompatible way, e.g., deleting a function
+// from an interface or a field from a parcelable and it broke the build. That
+// breakage is intended.
+//
+// You must not make a backward incompatible changes to the AIDL files built
+// with the aidl_interface module type with versions property set. The module
+// type is used to build AIDL files in a way that they can be used across
+// independently updatable components of the system. If a device is shipped
+// with such a backward incompatible change, it has a high risk of breaking
+// later when a module using the interface is updated, e.g., Mainline modules.
+
+package android.hardware.security.keymint;
+@VintfStability
+interface IKeyMintDevice {
+  android.hardware.security.keymint.KeyMintHardwareInfo getHardwareInfo();
+  android.hardware.security.keymint.VerificationToken verifyAuthorization(in long challenge, in android.hardware.security.keymint.HardwareAuthToken token);
+  void addRngEntropy(in byte[] data);
+  void generateKey(in android.hardware.security.keymint.KeyParameter[] keyParams, out android.hardware.security.keymint.ByteArray generatedKeyBlob, out android.hardware.security.keymint.KeyCharacteristics generatedKeyCharacteristics, out android.hardware.security.keymint.Certificate[] outCertChain);
+  void importKey(in android.hardware.security.keymint.KeyParameter[] inKeyParams, in android.hardware.security.keymint.KeyFormat inKeyFormat, in byte[] inKeyData, out android.hardware.security.keymint.ByteArray outImportedKeyBlob, out android.hardware.security.keymint.KeyCharacteristics outImportedKeyCharacteristics, out android.hardware.security.keymint.Certificate[] outCertChain);
+  void importWrappedKey(in byte[] inWrappedKeyData, in byte[] inWrappingKeyBlob, in byte[] inMaskingKey, in android.hardware.security.keymint.KeyParameter[] inUnwrappingParams, in long inPasswordSid, in long inBiometricSid, out android.hardware.security.keymint.ByteArray outImportedKeyBlob, out android.hardware.security.keymint.KeyCharacteristics outImportedKeyCharacteristics);
+  byte[] upgradeKey(in byte[] inKeyBlobToUpgrade, in android.hardware.security.keymint.KeyParameter[] inUpgradeParams);
+  void deleteKey(in byte[] inKeyBlob);
+  void deleteAllKeys();
+  void destroyAttestationIds();
+  android.hardware.security.keymint.BeginResult begin(in android.hardware.security.keymint.KeyPurpose inPurpose, in byte[] inKeyBlob, in android.hardware.security.keymint.KeyParameter[] inParams, in android.hardware.security.keymint.HardwareAuthToken inAuthToken);
+  const int AUTH_TOKEN_MAC_LENGTH = 32;
+}
diff --git a/security/keymint/aidl/aidl_api/android.hardware.security.keymint/current/android/hardware/security/keymint/IKeyMintOperation.aidl b/security/keymint/aidl/aidl_api/android.hardware.security.keymint/current/android/hardware/security/keymint/IKeyMintOperation.aidl
new file mode 100644
index 0000000..8e3b0fc
--- /dev/null
+++ b/security/keymint/aidl/aidl_api/android.hardware.security.keymint/current/android/hardware/security/keymint/IKeyMintOperation.aidl
@@ -0,0 +1,24 @@
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE.                          //
+///////////////////////////////////////////////////////////////////////////////
+
+// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
+// edit this file. It looks like you are doing that because you have modified
+// an AIDL interface in a backward-incompatible way, e.g., deleting a function
+// from an interface or a field from a parcelable and it broke the build. That
+// breakage is intended.
+//
+// You must not make a backward incompatible changes to the AIDL files built
+// with the aidl_interface module type with versions property set. The module
+// type is used to build AIDL files in a way that they can be used across
+// independently updatable components of the system. If a device is shipped
+// with such a backward incompatible change, it has a high risk of breaking
+// later when a module using the interface is updated, e.g., Mainline modules.
+
+package android.hardware.security.keymint;
+@VintfStability
+interface IKeyMintOperation {
+  int update(in @nullable android.hardware.security.keymint.KeyParameterArray inParams, in @nullable byte[] input, in @nullable android.hardware.security.keymint.HardwareAuthToken inAuthToken, in @nullable android.hardware.security.keymint.VerificationToken inVerificationToken, out @nullable android.hardware.security.keymint.KeyParameterArray outParams, out @nullable android.hardware.security.keymint.ByteArray output);
+  byte[] finish(in @nullable android.hardware.security.keymint.KeyParameterArray inParams, in @nullable byte[] input, in @nullable byte[] inSignature, in @nullable android.hardware.security.keymint.HardwareAuthToken authToken, in @nullable android.hardware.security.keymint.VerificationToken inVerificationToken, out @nullable android.hardware.security.keymint.KeyParameterArray outParams);
+  void abort();
+}
diff --git a/keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/KeyCharacteristics.aidl b/security/keymint/aidl/aidl_api/android.hardware.security.keymint/current/android/hardware/security/keymint/KeyCharacteristics.aidl
similarity index 85%
rename from keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/KeyCharacteristics.aidl
rename to security/keymint/aidl/aidl_api/android.hardware.security.keymint/current/android/hardware/security/keymint/KeyCharacteristics.aidl
index 4e73381..fb4214c 100644
--- a/keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/KeyCharacteristics.aidl
+++ b/security/keymint/aidl/aidl_api/android.hardware.security.keymint/current/android/hardware/security/keymint/KeyCharacteristics.aidl
@@ -15,9 +15,9 @@
 // with such a backward incompatible change, it has a high risk of breaking
 // later when a module using the interface is updated, e.g., Mainline modules.
 
-package android.hardware.keymint;
+package android.hardware.security.keymint;
 @VintfStability
 parcelable KeyCharacteristics {
-  android.hardware.keymint.KeyParameter[] softwareEnforced;
-  android.hardware.keymint.KeyParameter[] hardwareEnforced;
+  android.hardware.security.keymint.KeyParameter[] softwareEnforced;
+  android.hardware.security.keymint.KeyParameter[] hardwareEnforced;
 }
diff --git a/keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/KeyDerivationFunction.aidl b/security/keymint/aidl/aidl_api/android.hardware.security.keymint/current/android/hardware/security/keymint/KeyDerivationFunction.aidl
similarity index 96%
rename from keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/KeyDerivationFunction.aidl
rename to security/keymint/aidl/aidl_api/android.hardware.security.keymint/current/android/hardware/security/keymint/KeyDerivationFunction.aidl
index 8e2c774..83b7e6e 100644
--- a/keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/KeyDerivationFunction.aidl
+++ b/security/keymint/aidl/aidl_api/android.hardware.security.keymint/current/android/hardware/security/keymint/KeyDerivationFunction.aidl
@@ -15,7 +15,7 @@
 // with such a backward incompatible change, it has a high risk of breaking
 // later when a module using the interface is updated, e.g., Mainline modules.
 
-package android.hardware.keymint;
+package android.hardware.security.keymint;
 @Backing(type="int") @VintfStability
 enum KeyDerivationFunction {
   NONE = 0,
diff --git a/keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/KeyFormat.aidl b/security/keymint/aidl/aidl_api/android.hardware.security.keymint/current/android/hardware/security/keymint/KeyFormat.aidl
similarity index 95%
rename from keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/KeyFormat.aidl
rename to security/keymint/aidl/aidl_api/android.hardware.security.keymint/current/android/hardware/security/keymint/KeyFormat.aidl
index cfa585d..f701c80 100644
--- a/keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/KeyFormat.aidl
+++ b/security/keymint/aidl/aidl_api/android.hardware.security.keymint/current/android/hardware/security/keymint/KeyFormat.aidl
@@ -15,7 +15,7 @@
 // with such a backward incompatible change, it has a high risk of breaking
 // later when a module using the interface is updated, e.g., Mainline modules.
 
-package android.hardware.keymint;
+package android.hardware.security.keymint;
 @Backing(type="int") @VintfStability
 enum KeyFormat {
   X509 = 0,
diff --git a/keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/KeyMintHardwareInfo.aidl b/security/keymint/aidl/aidl_api/android.hardware.security.keymint/current/android/hardware/security/keymint/KeyMintHardwareInfo.aidl
similarity index 91%
rename from keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/KeyMintHardwareInfo.aidl
rename to security/keymint/aidl/aidl_api/android.hardware.security.keymint/current/android/hardware/security/keymint/KeyMintHardwareInfo.aidl
index 8263e60..5e9f7ae 100644
--- a/keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/KeyMintHardwareInfo.aidl
+++ b/security/keymint/aidl/aidl_api/android.hardware.security.keymint/current/android/hardware/security/keymint/KeyMintHardwareInfo.aidl
@@ -15,11 +15,11 @@
 // with such a backward incompatible change, it has a high risk of breaking
 // later when a module using the interface is updated, e.g., Mainline modules.
 
-package android.hardware.keymint;
+package android.hardware.security.keymint;
 @VintfStability
 parcelable KeyMintHardwareInfo {
   int versionNumber;
-  android.hardware.keymint.SecurityLevel securityLevel;
+  android.hardware.security.keymint.SecurityLevel securityLevel;
   @utf8InCpp String keyMintName;
   @utf8InCpp String keyMintAuthorName;
 }
diff --git a/keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/KeyOrigin.aidl b/security/keymint/aidl/aidl_api/android.hardware.security.keymint/current/android/hardware/security/keymint/KeyOrigin.aidl
similarity index 96%
rename from keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/KeyOrigin.aidl
rename to security/keymint/aidl/aidl_api/android.hardware.security.keymint/current/android/hardware/security/keymint/KeyOrigin.aidl
index 8d03d2b..9728bf9 100644
--- a/keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/KeyOrigin.aidl
+++ b/security/keymint/aidl/aidl_api/android.hardware.security.keymint/current/android/hardware/security/keymint/KeyOrigin.aidl
@@ -15,7 +15,7 @@
 // with such a backward incompatible change, it has a high risk of breaking
 // later when a module using the interface is updated, e.g., Mainline modules.
 
-package android.hardware.keymint;
+package android.hardware.security.keymint;
 @Backing(type="int") @VintfStability
 enum KeyOrigin {
   GENERATED = 0,
diff --git a/keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/KeyParameter.aidl b/security/keymint/aidl/aidl_api/android.hardware.security.keymint/current/android/hardware/security/keymint/KeyParameter.aidl
similarity index 92%
rename from keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/KeyParameter.aidl
rename to security/keymint/aidl/aidl_api/android.hardware.security.keymint/current/android/hardware/security/keymint/KeyParameter.aidl
index 923cc68..91f83e4 100644
--- a/keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/KeyParameter.aidl
+++ b/security/keymint/aidl/aidl_api/android.hardware.security.keymint/current/android/hardware/security/keymint/KeyParameter.aidl
@@ -15,10 +15,10 @@
 // with such a backward incompatible change, it has a high risk of breaking
 // later when a module using the interface is updated, e.g., Mainline modules.
 
-package android.hardware.keymint;
+package android.hardware.security.keymint;
 @VintfStability
 parcelable KeyParameter {
-  android.hardware.keymint.Tag tag;
+  android.hardware.security.keymint.Tag tag;
   boolean boolValue;
   int integer;
   long longInteger;
diff --git a/keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/KeyParameterArray.aidl b/security/keymint/aidl/aidl_api/android.hardware.security.keymint/current/android/hardware/security/keymint/KeyParameterArray.aidl
similarity index 91%
rename from keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/KeyParameterArray.aidl
rename to security/keymint/aidl/aidl_api/android.hardware.security.keymint/current/android/hardware/security/keymint/KeyParameterArray.aidl
index b9b9782..2c3b768 100644
--- a/keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/KeyParameterArray.aidl
+++ b/security/keymint/aidl/aidl_api/android.hardware.security.keymint/current/android/hardware/security/keymint/KeyParameterArray.aidl
@@ -15,8 +15,8 @@
 // with such a backward incompatible change, it has a high risk of breaking
 // later when a module using the interface is updated, e.g., Mainline modules.
 
-package android.hardware.keymint;
+package android.hardware.security.keymint;
 @VintfStability
 parcelable KeyParameterArray {
-  android.hardware.keymint.KeyParameter[] params;
+  android.hardware.security.keymint.KeyParameter[] params;
 }
diff --git a/keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/KeyPurpose.aidl b/security/keymint/aidl/aidl_api/android.hardware.security.keymint/current/android/hardware/security/keymint/KeyPurpose.aidl
similarity index 96%
rename from keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/KeyPurpose.aidl
rename to security/keymint/aidl/aidl_api/android.hardware.security.keymint/current/android/hardware/security/keymint/KeyPurpose.aidl
index 1aee56a..a6fd8c3 100644
--- a/keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/KeyPurpose.aidl
+++ b/security/keymint/aidl/aidl_api/android.hardware.security.keymint/current/android/hardware/security/keymint/KeyPurpose.aidl
@@ -15,7 +15,7 @@
 // with such a backward incompatible change, it has a high risk of breaking
 // later when a module using the interface is updated, e.g., Mainline modules.
 
-package android.hardware.keymint;
+package android.hardware.security.keymint;
 @Backing(type="int") @VintfStability
 enum KeyPurpose {
   ENCRYPT = 0,
diff --git a/keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/PaddingMode.aidl b/security/keymint/aidl/aidl_api/android.hardware.security.keymint/current/android/hardware/security/keymint/PaddingMode.aidl
similarity index 96%
rename from keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/PaddingMode.aidl
rename to security/keymint/aidl/aidl_api/android.hardware.security.keymint/current/android/hardware/security/keymint/PaddingMode.aidl
index 97f93db..2ecfa1e 100644
--- a/keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/PaddingMode.aidl
+++ b/security/keymint/aidl/aidl_api/android.hardware.security.keymint/current/android/hardware/security/keymint/PaddingMode.aidl
@@ -15,7 +15,7 @@
 // with such a backward incompatible change, it has a high risk of breaking
 // later when a module using the interface is updated, e.g., Mainline modules.
 
-package android.hardware.keymint;
+package android.hardware.security.keymint;
 @Backing(type="int") @VintfStability
 enum PaddingMode {
   NONE = 1,
diff --git a/keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/SecurityLevel.aidl b/security/keymint/aidl/aidl_api/android.hardware.security.keymint/current/android/hardware/security/keymint/SecurityLevel.aidl
similarity index 95%
rename from keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/SecurityLevel.aidl
rename to security/keymint/aidl/aidl_api/android.hardware.security.keymint/current/android/hardware/security/keymint/SecurityLevel.aidl
index 1fb529d..601693f 100644
--- a/keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/SecurityLevel.aidl
+++ b/security/keymint/aidl/aidl_api/android.hardware.security.keymint/current/android/hardware/security/keymint/SecurityLevel.aidl
@@ -15,7 +15,7 @@
 // with such a backward incompatible change, it has a high risk of breaking
 // later when a module using the interface is updated, e.g., Mainline modules.
 
-package android.hardware.keymint;
+package android.hardware.security.keymint;
 @Backing(type="int") @VintfStability
 enum SecurityLevel {
   SOFTWARE = 0,
diff --git a/keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/Tag.aidl b/security/keymint/aidl/aidl_api/android.hardware.security.keymint/current/android/hardware/security/keymint/Tag.aidl
similarity index 98%
rename from keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/Tag.aidl
rename to security/keymint/aidl/aidl_api/android.hardware.security.keymint/current/android/hardware/security/keymint/Tag.aidl
index 33a95fe..38eb6e6 100644
--- a/keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/Tag.aidl
+++ b/security/keymint/aidl/aidl_api/android.hardware.security.keymint/current/android/hardware/security/keymint/Tag.aidl
@@ -15,7 +15,7 @@
 // with such a backward incompatible change, it has a high risk of breaking
 // later when a module using the interface is updated, e.g., Mainline modules.
 
-package android.hardware.keymint;
+package android.hardware.security.keymint;
 @Backing(type="int") @VintfStability
 enum Tag {
   INVALID = 0,
diff --git a/keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/TagType.aidl b/security/keymint/aidl/aidl_api/android.hardware.security.keymint/current/android/hardware/security/keymint/TagType.aidl
similarity index 96%
rename from keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/TagType.aidl
rename to security/keymint/aidl/aidl_api/android.hardware.security.keymint/current/android/hardware/security/keymint/TagType.aidl
index 8214453..bb2766c 100644
--- a/keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/TagType.aidl
+++ b/security/keymint/aidl/aidl_api/android.hardware.security.keymint/current/android/hardware/security/keymint/TagType.aidl
@@ -15,7 +15,7 @@
 // with such a backward incompatible change, it has a high risk of breaking
 // later when a module using the interface is updated, e.g., Mainline modules.
 
-package android.hardware.keymint;
+package android.hardware.security.keymint;
 @Backing(type="int") @VintfStability
 enum TagType {
   INVALID = 0,
diff --git a/keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/Timestamp.aidl b/security/keymint/aidl/aidl_api/android.hardware.security.keymint/current/android/hardware/security/keymint/Timestamp.aidl
similarity index 95%
rename from keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/Timestamp.aidl
rename to security/keymint/aidl/aidl_api/android.hardware.security.keymint/current/android/hardware/security/keymint/Timestamp.aidl
index f95d8db..4d5b659 100644
--- a/keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/Timestamp.aidl
+++ b/security/keymint/aidl/aidl_api/android.hardware.security.keymint/current/android/hardware/security/keymint/Timestamp.aidl
@@ -15,7 +15,7 @@
 // with such a backward incompatible change, it has a high risk of breaking
 // later when a module using the interface is updated, e.g., Mainline modules.
 
-package android.hardware.keymint;
+package android.hardware.security.keymint;
 @VintfStability
 parcelable Timestamp {
   long milliSeconds;
diff --git a/keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/VerificationToken.aidl b/security/keymint/aidl/aidl_api/android.hardware.security.keymint/current/android/hardware/security/keymint/VerificationToken.aidl
similarity index 86%
rename from keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/VerificationToken.aidl
rename to security/keymint/aidl/aidl_api/android.hardware.security.keymint/current/android/hardware/security/keymint/VerificationToken.aidl
index 7b4989a..5c76816 100644
--- a/keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/VerificationToken.aidl
+++ b/security/keymint/aidl/aidl_api/android.hardware.security.keymint/current/android/hardware/security/keymint/VerificationToken.aidl
@@ -15,11 +15,11 @@
 // with such a backward incompatible change, it has a high risk of breaking
 // later when a module using the interface is updated, e.g., Mainline modules.
 
-package android.hardware.keymint;
+package android.hardware.security.keymint;
 @VintfStability
 parcelable VerificationToken {
   long challenge;
-  android.hardware.keymint.Timestamp timestamp;
-  android.hardware.keymint.SecurityLevel securityLevel;
+  android.hardware.security.keymint.Timestamp timestamp;
+  android.hardware.security.keymint.SecurityLevel securityLevel;
   byte[] mac;
 }
diff --git a/keymint/aidl/android/hardware/keymint/Algorithm.aidl b/security/keymint/aidl/android/hardware/security/keymint/Algorithm.aidl
similarity index 95%
rename from keymint/aidl/android/hardware/keymint/Algorithm.aidl
rename to security/keymint/aidl/android/hardware/security/keymint/Algorithm.aidl
index 8c5d99c..8300b0d 100644
--- a/keymint/aidl/android/hardware/keymint/Algorithm.aidl
+++ b/security/keymint/aidl/android/hardware/security/keymint/Algorithm.aidl
@@ -14,8 +14,7 @@
  * limitations under the License.
  */
 
-package android.hardware.keymint;
-
+package android.hardware.security.keymint;
 
 /**
  * Algorithms provided by IKeyMintDevice implementations.
diff --git a/keymint/aidl/android/hardware/keymint/BeginResult.aidl b/security/keymint/aidl/android/hardware/security/keymint/BeginResult.aidl
similarity index 87%
rename from keymint/aidl/android/hardware/keymint/BeginResult.aidl
rename to security/keymint/aidl/android/hardware/security/keymint/BeginResult.aidl
index 58eb024..aaf9f3c 100644
--- a/keymint/aidl/android/hardware/keymint/BeginResult.aidl
+++ b/security/keymint/aidl/android/hardware/security/keymint/BeginResult.aidl
@@ -14,12 +14,10 @@
  * limitations under the License.
  */
 
-package android.hardware.keymint;
+package android.hardware.security.keymint;
 
-
-import android.hardware.keymint.IKeyMintOperation;
-import android.hardware.keymint.KeyParameter;
-
+import android.hardware.security.keymint.IKeyMintOperation;
+import android.hardware.security.keymint.KeyParameter;
 
 /**
  * This is all the results returned by the IKeyMintDevice begin() function.
diff --git a/keymint/aidl/android/hardware/keymint/BlockMode.aidl b/security/keymint/aidl/android/hardware/security/keymint/BlockMode.aidl
similarity index 95%
rename from keymint/aidl/android/hardware/keymint/BlockMode.aidl
rename to security/keymint/aidl/android/hardware/security/keymint/BlockMode.aidl
index b6b36cc..629c89f 100644
--- a/keymint/aidl/android/hardware/keymint/BlockMode.aidl
+++ b/security/keymint/aidl/android/hardware/security/keymint/BlockMode.aidl
@@ -14,8 +14,7 @@
  * limitations under the License.
  */
 
-package android.hardware.keymint;
-
+package android.hardware.security.keymint;
 
 /**
  * Symmetric block cipher modes provided by IKeyMintDevice implementations.
diff --git a/keymint/aidl/android/hardware/keymint/ByteArray.aidl b/security/keymint/aidl/android/hardware/security/keymint/ByteArray.aidl
similarity index 94%
rename from keymint/aidl/android/hardware/keymint/ByteArray.aidl
rename to security/keymint/aidl/android/hardware/security/keymint/ByteArray.aidl
index 18d187e..c3b402e 100644
--- a/keymint/aidl/android/hardware/keymint/ByteArray.aidl
+++ b/security/keymint/aidl/android/hardware/security/keymint/ByteArray.aidl
@@ -14,8 +14,7 @@
  * limitations under the License.
  */
 
-package android.hardware.keymint;
-
+package android.hardware.security.keymint;
 
 /**
  * This is used to contain a byte[], to make out parameters of byte arrays
diff --git a/keymint/aidl/android/hardware/keymint/Certificate.aidl b/security/keymint/aidl/android/hardware/security/keymint/Certificate.aidl
similarity index 94%
rename from keymint/aidl/android/hardware/keymint/Certificate.aidl
rename to security/keymint/aidl/android/hardware/security/keymint/Certificate.aidl
index 3a70970..a953859 100644
--- a/keymint/aidl/android/hardware/keymint/Certificate.aidl
+++ b/security/keymint/aidl/android/hardware/security/keymint/Certificate.aidl
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package android.hardware.keymint;
+package android.hardware.security.keymint;
 
 /**
  * This encodes the IKeyMintDevice attestation generated certificate.
diff --git a/keymint/aidl/android/hardware/keymint/Digest.aidl b/security/keymint/aidl/android/hardware/security/keymint/Digest.aidl
similarity index 94%
rename from keymint/aidl/android/hardware/keymint/Digest.aidl
rename to security/keymint/aidl/android/hardware/security/keymint/Digest.aidl
index a92ac23..b44da5a 100644
--- a/keymint/aidl/android/hardware/keymint/Digest.aidl
+++ b/security/keymint/aidl/android/hardware/security/keymint/Digest.aidl
@@ -14,8 +14,7 @@
  * limitations under the License.
  */
 
-package android.hardware.keymint;
-
+package android.hardware.security.keymint;
 
 /**
  * Digests provided by keyMint implementations.
diff --git a/keymint/aidl/android/hardware/keymint/EcCurve.aidl b/security/keymint/aidl/android/hardware/security/keymint/EcCurve.aidl
similarity index 94%
rename from keymint/aidl/android/hardware/keymint/EcCurve.aidl
rename to security/keymint/aidl/android/hardware/security/keymint/EcCurve.aidl
index abd44b4..b9d1646 100644
--- a/keymint/aidl/android/hardware/keymint/EcCurve.aidl
+++ b/security/keymint/aidl/android/hardware/security/keymint/EcCurve.aidl
@@ -14,8 +14,7 @@
  * limitations under the License.
  */
 
-package android.hardware.keymint;
-
+package android.hardware.security.keymint;
 
 /**
  * Supported EC curves, used in ECDSA
diff --git a/keymint/aidl/android/hardware/keymint/ErrorCode.aidl b/security/keymint/aidl/android/hardware/security/keymint/ErrorCode.aidl
similarity index 98%
rename from keymint/aidl/android/hardware/keymint/ErrorCode.aidl
rename to security/keymint/aidl/android/hardware/security/keymint/ErrorCode.aidl
index 2a54954..fb24ad1 100644
--- a/keymint/aidl/android/hardware/keymint/ErrorCode.aidl
+++ b/security/keymint/aidl/android/hardware/security/keymint/ErrorCode.aidl
@@ -14,8 +14,7 @@
  * limitations under the License.
  */
 
-package android.hardware.keymint;
-
+package android.hardware.security.keymint;
 
 /**
  * KeyMint error codes.  Aidl will return these error codes as service specific
diff --git a/keymint/aidl/android/hardware/keymint/HardwareAuthToken.aidl b/security/keymint/aidl/android/hardware/security/keymint/HardwareAuthToken.aidl
similarity index 95%
rename from keymint/aidl/android/hardware/keymint/HardwareAuthToken.aidl
rename to security/keymint/aidl/android/hardware/security/keymint/HardwareAuthToken.aidl
index 9b56a2e..12d615f 100644
--- a/keymint/aidl/android/hardware/keymint/HardwareAuthToken.aidl
+++ b/security/keymint/aidl/android/hardware/security/keymint/HardwareAuthToken.aidl
@@ -14,10 +14,10 @@
  * limitations under the License.
  */
 
-package android.hardware.keymint;
+package android.hardware.security.keymint;
 
-import android.hardware.keymint.Timestamp;
-import android.hardware.keymint.HardwareAuthenticatorType;
+import android.hardware.security.keymint.Timestamp;
+import android.hardware.security.keymint.HardwareAuthenticatorType;
 
 /**
  * HardwareAuthToken is used to prove successful user authentication, to unlock the use of a key.
@@ -30,7 +30,6 @@
  */
 @VintfStability
 parcelable HardwareAuthToken {
-
     /**
      * challenge is a value that's used to enable authentication tokens to authorize specific
      * events.  The primary use case for challenge is to authorize an IKeyMintDevice cryptographic
diff --git a/keymint/aidl/android/hardware/keymint/HardwareAuthenticatorType.aidl b/security/keymint/aidl/android/hardware/security/keymint/HardwareAuthenticatorType.aidl
similarity index 95%
rename from keymint/aidl/android/hardware/keymint/HardwareAuthenticatorType.aidl
rename to security/keymint/aidl/android/hardware/security/keymint/HardwareAuthenticatorType.aidl
index 5c25e2f..33f71b8 100644
--- a/keymint/aidl/android/hardware/keymint/HardwareAuthenticatorType.aidl
+++ b/security/keymint/aidl/android/hardware/security/keymint/HardwareAuthenticatorType.aidl
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package android.hardware.keymint;
+package android.hardware.security.keymint;
 
 /**
  * Hardware authentication type, used by HardwareAuthTokens to specify the mechanism used to
diff --git a/keymint/aidl/android/hardware/keymint/IKeyMintDevice.aidl b/security/keymint/aidl/android/hardware/security/keymint/IKeyMintDevice.aidl
similarity index 98%
rename from keymint/aidl/android/hardware/keymint/IKeyMintDevice.aidl
rename to security/keymint/aidl/android/hardware/security/keymint/IKeyMintDevice.aidl
index 8fbab79..4944acb 100644
--- a/keymint/aidl/android/hardware/keymint/IKeyMintDevice.aidl
+++ b/security/keymint/aidl/android/hardware/security/keymint/IKeyMintDevice.aidl
@@ -14,20 +14,20 @@
  * limitations under the License.
  */
 
-package android.hardware.keymint;
+package android.hardware.security.keymint;
 
-import android.hardware.keymint.BeginResult;
-import android.hardware.keymint.ByteArray;
-import android.hardware.keymint.Certificate;
-import android.hardware.keymint.HardwareAuthToken;
-import android.hardware.keymint.IKeyMintOperation;
-import android.hardware.keymint.KeyCharacteristics;
-import android.hardware.keymint.KeyFormat;
-import android.hardware.keymint.KeyParameter;
-import android.hardware.keymint.KeyMintHardwareInfo;
-import android.hardware.keymint.KeyPurpose;
-import android.hardware.keymint.SecurityLevel;
-import android.hardware.keymint.VerificationToken;
+import android.hardware.security.keymint.BeginResult;
+import android.hardware.security.keymint.ByteArray;
+import android.hardware.security.keymint.Certificate;
+import android.hardware.security.keymint.HardwareAuthToken;
+import android.hardware.security.keymint.IKeyMintOperation;
+import android.hardware.security.keymint.KeyCharacteristics;
+import android.hardware.security.keymint.KeyFormat;
+import android.hardware.security.keymint.KeyParameter;
+import android.hardware.security.keymint.KeyMintHardwareInfo;
+import android.hardware.security.keymint.KeyPurpose;
+import android.hardware.security.keymint.SecurityLevel;
+import android.hardware.security.keymint.VerificationToken;
 
 /**
  * KeyMint device definition.
diff --git a/keymint/aidl/android/hardware/keymint/IKeyMintOperation.aidl b/security/keymint/aidl/android/hardware/security/keymint/IKeyMintOperation.aidl
similarity index 97%
rename from keymint/aidl/android/hardware/keymint/IKeyMintOperation.aidl
rename to security/keymint/aidl/android/hardware/security/keymint/IKeyMintOperation.aidl
index 1b79296..24960cc 100644
--- a/keymint/aidl/android/hardware/keymint/IKeyMintOperation.aidl
+++ b/security/keymint/aidl/android/hardware/security/keymint/IKeyMintOperation.aidl
@@ -14,13 +14,13 @@
  * limitations under the License.
  */
 
-package android.hardware.keymint;
+package android.hardware.security.keymint;
 
-import android.hardware.keymint.ByteArray;
-import android.hardware.keymint.HardwareAuthToken;
-import android.hardware.keymint.KeyParameter;
-import android.hardware.keymint.KeyParameterArray;
-import android.hardware.keymint.VerificationToken;
+import android.hardware.security.keymint.ByteArray;
+import android.hardware.security.keymint.HardwareAuthToken;
+import android.hardware.security.keymint.KeyParameter;
+import android.hardware.security.keymint.KeyParameterArray;
+import android.hardware.security.keymint.VerificationToken;
 
 @VintfStability
 interface IKeyMintOperation {
diff --git a/keymint/aidl/android/hardware/keymint/KeyCharacteristics.aidl b/security/keymint/aidl/android/hardware/security/keymint/KeyCharacteristics.aidl
similarity index 94%
rename from keymint/aidl/android/hardware/keymint/KeyCharacteristics.aidl
rename to security/keymint/aidl/android/hardware/security/keymint/KeyCharacteristics.aidl
index ac7c2b4..0801868 100644
--- a/keymint/aidl/android/hardware/keymint/KeyCharacteristics.aidl
+++ b/security/keymint/aidl/android/hardware/security/keymint/KeyCharacteristics.aidl
@@ -14,9 +14,9 @@
  * limitations under the License.
  */
 
-package android.hardware.keymint;
+package android.hardware.security.keymint;
 
-import android.hardware.keymint.KeyParameter;
+import android.hardware.security.keymint.KeyParameter;
 
 /**
  * KeyCharacteristics defines the attributes of a key, including cryptographic parameters, and usage
diff --git a/keymint/aidl/android/hardware/keymint/KeyDerivationFunction.aidl b/security/keymint/aidl/android/hardware/security/keymint/KeyDerivationFunction.aidl
similarity index 96%
rename from keymint/aidl/android/hardware/keymint/KeyDerivationFunction.aidl
rename to security/keymint/aidl/android/hardware/security/keymint/KeyDerivationFunction.aidl
index 1eba446..e166ab6 100644
--- a/keymint/aidl/android/hardware/keymint/KeyDerivationFunction.aidl
+++ b/security/keymint/aidl/android/hardware/security/keymint/KeyDerivationFunction.aidl
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package android.hardware.keymint;
+package android.hardware.security.keymint;
 
 /**
  * Key derivation functions, mostly used in ECIES.
diff --git a/keymint/aidl/android/hardware/keymint/KeyFormat.aidl b/security/keymint/aidl/android/hardware/security/keymint/KeyFormat.aidl
similarity index 95%
rename from keymint/aidl/android/hardware/keymint/KeyFormat.aidl
rename to security/keymint/aidl/android/hardware/security/keymint/KeyFormat.aidl
index 13044dc..6ad8e3d 100644
--- a/keymint/aidl/android/hardware/keymint/KeyFormat.aidl
+++ b/security/keymint/aidl/android/hardware/security/keymint/KeyFormat.aidl
@@ -14,8 +14,7 @@
  * limitations under the License.
  */
 
-package android.hardware.keymint;
-
+package android.hardware.security.keymint;
 
 /**
  * Formats for key import and export.
diff --git a/keymint/aidl/android/hardware/keymint/KeyMintHardwareInfo.aidl b/security/keymint/aidl/android/hardware/security/keymint/KeyMintHardwareInfo.aidl
similarity index 94%
rename from keymint/aidl/android/hardware/keymint/KeyMintHardwareInfo.aidl
rename to security/keymint/aidl/android/hardware/security/keymint/KeyMintHardwareInfo.aidl
index 5815b10..d3d7368 100644
--- a/keymint/aidl/android/hardware/keymint/KeyMintHardwareInfo.aidl
+++ b/security/keymint/aidl/android/hardware/security/keymint/KeyMintHardwareInfo.aidl
@@ -14,15 +14,13 @@
  * limitations under the License.
  */
 
-package android.hardware.keymint;
+package android.hardware.security.keymint;
 
-import android.hardware.keymint.SecurityLevel;
-
+import android.hardware.security.keymint.SecurityLevel;
 
 /**
  * KeyMintHardwareInfo is the hardware information returned by calling KeyMint getHardwareInfo()
  */
-
 @VintfStability
 parcelable KeyMintHardwareInfo {
     /**
diff --git a/keymint/aidl/android/hardware/keymint/KeyOrigin.aidl b/security/keymint/aidl/android/hardware/security/keymint/KeyOrigin.aidl
similarity index 96%
rename from keymint/aidl/android/hardware/keymint/KeyOrigin.aidl
rename to security/keymint/aidl/android/hardware/security/keymint/KeyOrigin.aidl
index 70320d3..0cd53c2 100644
--- a/keymint/aidl/android/hardware/keymint/KeyOrigin.aidl
+++ b/security/keymint/aidl/android/hardware/security/keymint/KeyOrigin.aidl
@@ -14,8 +14,7 @@
  * limitations under the License.
  */
 
-package android.hardware.keymint;
-
+package android.hardware.security.keymint;
 
 /**
  * The origin of a key (or pair), i.e. where it was generated.  Note that ORIGIN can be found in
diff --git a/keymint/aidl/android/hardware/keymint/KeyParameter.aidl b/security/keymint/aidl/android/hardware/security/keymint/KeyParameter.aidl
similarity index 70%
rename from keymint/aidl/android/hardware/keymint/KeyParameter.aidl
rename to security/keymint/aidl/android/hardware/security/keymint/KeyParameter.aidl
index d58e4aa..938064c 100644
--- a/keymint/aidl/android/hardware/keymint/KeyParameter.aidl
+++ b/security/keymint/aidl/android/hardware/security/keymint/KeyParameter.aidl
@@ -14,20 +14,19 @@
  * limitations under the License.
  */
 
-package android.hardware.keymint;
+package android.hardware.security.keymint;
 
-
-import android.hardware.keymint.Algorithm;
-import android.hardware.keymint.BlockMode;
-import android.hardware.keymint.Digest;
-import android.hardware.keymint.EcCurve;
-import android.hardware.keymint.HardwareAuthenticatorType;
-import android.hardware.keymint.KeyDerivationFunction;
-import android.hardware.keymint.KeyOrigin;
-import android.hardware.keymint.KeyPurpose;
-import android.hardware.keymint.PaddingMode;
-import android.hardware.keymint.SecurityLevel;
-import android.hardware.keymint.Tag;
+import android.hardware.security.keymint.Algorithm;
+import android.hardware.security.keymint.BlockMode;
+import android.hardware.security.keymint.Digest;
+import android.hardware.security.keymint.EcCurve;
+import android.hardware.security.keymint.HardwareAuthenticatorType;
+import android.hardware.security.keymint.KeyDerivationFunction;
+import android.hardware.security.keymint.KeyOrigin;
+import android.hardware.security.keymint.KeyPurpose;
+import android.hardware.security.keymint.PaddingMode;
+import android.hardware.security.keymint.SecurityLevel;
+import android.hardware.security.keymint.Tag;
 
 
 /**
diff --git a/keymint/aidl/android/hardware/keymint/KeyParameterArray.aidl b/security/keymint/aidl/android/hardware/security/keymint/KeyParameterArray.aidl
similarity index 90%
rename from keymint/aidl/android/hardware/keymint/KeyParameterArray.aidl
rename to security/keymint/aidl/android/hardware/security/keymint/KeyParameterArray.aidl
index cc9e37a..acab435 100644
--- a/keymint/aidl/android/hardware/keymint/KeyParameterArray.aidl
+++ b/security/keymint/aidl/android/hardware/security/keymint/KeyParameterArray.aidl
@@ -14,9 +14,9 @@
  * limitations under the License.
  */
 
-package android.hardware.keymint;
+package android.hardware.security.keymint;
 
-import android.hardware.keymint.KeyParameter;
+import android.hardware.security.keymint.KeyParameter;
 
 /**
  * Identifies the key authorization parameters to be used with keyMint.  This is usually
diff --git a/keymint/aidl/android/hardware/keymint/KeyPurpose.aidl b/security/keymint/aidl/android/hardware/security/keymint/KeyPurpose.aidl
similarity index 95%
rename from keymint/aidl/android/hardware/keymint/KeyPurpose.aidl
rename to security/keymint/aidl/android/hardware/security/keymint/KeyPurpose.aidl
index bc029fd..cb4682e 100644
--- a/keymint/aidl/android/hardware/keymint/KeyPurpose.aidl
+++ b/security/keymint/aidl/android/hardware/security/keymint/KeyPurpose.aidl
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package android.hardware.keymint;
+package android.hardware.security.keymint;
 
 
 /**
diff --git a/keymint/aidl/android/hardware/keymint/PaddingMode.aidl b/security/keymint/aidl/android/hardware/security/keymint/PaddingMode.aidl
similarity index 96%
rename from keymint/aidl/android/hardware/keymint/PaddingMode.aidl
rename to security/keymint/aidl/android/hardware/security/keymint/PaddingMode.aidl
index 337ed91..80b73bd 100644
--- a/keymint/aidl/android/hardware/keymint/PaddingMode.aidl
+++ b/security/keymint/aidl/android/hardware/security/keymint/PaddingMode.aidl
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package android.hardware.keymint;
+package android.hardware.security.keymint;
 
 /**
  * TODO(seleneh) update the description.
diff --git a/keymint/aidl/android/hardware/keymint/SecurityLevel.aidl b/security/keymint/aidl/android/hardware/security/keymint/SecurityLevel.aidl
similarity index 95%
rename from keymint/aidl/android/hardware/keymint/SecurityLevel.aidl
rename to security/keymint/aidl/android/hardware/security/keymint/SecurityLevel.aidl
index d8de024..10363e9 100644
--- a/keymint/aidl/android/hardware/keymint/SecurityLevel.aidl
+++ b/security/keymint/aidl/android/hardware/security/keymint/SecurityLevel.aidl
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package android.hardware.keymint;
+package android.hardware.security.keymint;
 
 /**
  * Device security levels.
diff --git a/keymint/aidl/android/hardware/keymint/Tag.aidl b/security/keymint/aidl/android/hardware/security/keymint/Tag.aidl
similarity index 99%
rename from keymint/aidl/android/hardware/keymint/Tag.aidl
rename to security/keymint/aidl/android/hardware/security/keymint/Tag.aidl
index 46da096..532bc5d 100644
--- a/keymint/aidl/android/hardware/keymint/Tag.aidl
+++ b/security/keymint/aidl/android/hardware/security/keymint/Tag.aidl
@@ -14,9 +14,9 @@
  * limitations under the License.
  */
 
-package android.hardware.keymint;
+package android.hardware.security.keymint;
 
-import android.hardware.keymint.TagType;
+import android.hardware.security.keymint.TagType;
 
 // TODO(seleneh) : note aidl currently does not support double nested enum definitions such as
 // ROOT_OF_TRUST = TagType:BYTES | 704.  So we are forced to write definations as
diff --git a/keymint/aidl/android/hardware/keymint/TagType.aidl b/security/keymint/aidl/android/hardware/security/keymint/TagType.aidl
similarity index 96%
rename from keymint/aidl/android/hardware/keymint/TagType.aidl
rename to security/keymint/aidl/android/hardware/security/keymint/TagType.aidl
index fb50b10..a273af3 100644
--- a/keymint/aidl/android/hardware/keymint/TagType.aidl
+++ b/security/keymint/aidl/android/hardware/security/keymint/TagType.aidl
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package android.hardware.keymint;
+package android.hardware.security.keymint;
 
 /**
  * TagType classifies Tags in Tag.aidl into various groups of data.
diff --git a/keymint/aidl/android/hardware/keymint/Timestamp.aidl b/security/keymint/aidl/android/hardware/security/keymint/Timestamp.aidl
similarity index 95%
rename from keymint/aidl/android/hardware/keymint/Timestamp.aidl
rename to security/keymint/aidl/android/hardware/security/keymint/Timestamp.aidl
index 7c882c6..ebb3684 100644
--- a/keymint/aidl/android/hardware/keymint/Timestamp.aidl
+++ b/security/keymint/aidl/android/hardware/security/keymint/Timestamp.aidl
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package android.hardware.keymint;
+package android.hardware.security.keymint;
 
 /**
  * Time in milliseconds since some arbitrary point in time.  Time must be monotonically increasing,
diff --git a/keymint/aidl/android/hardware/keymint/VerificationToken.aidl b/security/keymint/aidl/android/hardware/security/keymint/VerificationToken.aidl
similarity index 79%
rename from keymint/aidl/android/hardware/keymint/VerificationToken.aidl
rename to security/keymint/aidl/android/hardware/security/keymint/VerificationToken.aidl
index 736c0e2..f76e6a8 100644
--- a/keymint/aidl/android/hardware/keymint/VerificationToken.aidl
+++ b/security/keymint/aidl/android/hardware/security/keymint/VerificationToken.aidl
@@ -14,10 +14,10 @@
  * limitations under the License.
  */
 
-package android.hardware.keymint;
+package android.hardware.security.keymint;
 
-import android.hardware.keymint.SecurityLevel;
-import android.hardware.keymint.Timestamp;
+import android.hardware.security.keymint.SecurityLevel;
+import android.hardware.security.keymint.Timestamp;
 
 /**
  * VerificationToken instances are used for secure environments to authenticate one another.
@@ -48,7 +48,7 @@
      * 32-byte HMAC-SHA256 of the above values, computed as:
      *
      *    HMAC(H,
-     *         "Auth Verification" || challenge || timestamp || securityLevel || parametersVerified)
+     *         "Auth Verification" || challenge || timestamp || securityLevel)
      *
      * where:
      *
@@ -58,11 +58,6 @@
      *
      * The representation of challenge and timestamp is as 64-bit unsigned integers in big-endian
      * order.  securityLevel is represented as a 32-bit unsigned integer in big-endian order.
-     *
-     * If parametersVerified is non-empty, the representation of parametersVerified is an ASN.1 DER
-     * encoded representation of the values.  The ASN.1 schema used is the AuthorizationList schema
-     * from the Keystore attestation documentation.  If parametersVerified is empty, it is simply
-     * omitted from the HMAC computation.
      */
     byte[] mac;
 }
diff --git a/security/keymint/aidl/default/Android.bp b/security/keymint/aidl/default/Android.bp
new file mode 100644
index 0000000..491a2c1
--- /dev/null
+++ b/security/keymint/aidl/default/Android.bp
@@ -0,0 +1,26 @@
+cc_binary {
+    name: "android.hardware.security.keymint-service",
+    relative_install_path: "hw",
+    init_rc: ["android.hardware.security.keymint-service.rc"],
+    vintf_fragments: ["android.hardware.security.keymint-service.xml"],
+    vendor: true,
+    cflags: [
+        "-Wall",
+        "-Wextra",
+    ],
+    shared_libs: [
+        "android.hardware.security.keymint-ndk_platform",
+        "libbase",
+        "libbinder_ndk",
+        "libcppbor",
+        "libcrypto",
+        "libkeymaster_portable",
+        "libkeymint",
+        "liblog",
+        "libpuresoftkeymasterdevice",
+        "libutils",
+    ],
+    srcs: [
+        "service.cpp",
+    ],
+}
diff --git a/security/keymint/aidl/default/android.hardware.security.keymint-service.rc b/security/keymint/aidl/default/android.hardware.security.keymint-service.rc
new file mode 100644
index 0000000..0c3a6e1
--- /dev/null
+++ b/security/keymint/aidl/default/android.hardware.security.keymint-service.rc
@@ -0,0 +1,3 @@
+service vendor.keymint-default /vendor/bin/hw/android.hardware.security.keymint-service
+    class early_hal
+    user nobody
diff --git a/keymint/aidl/default/android.hardware.keymint@1.0-service.xml b/security/keymint/aidl/default/android.hardware.security.keymint-service.xml
similarity index 70%
rename from keymint/aidl/default/android.hardware.keymint@1.0-service.xml
rename to security/keymint/aidl/default/android.hardware.security.keymint-service.xml
index 3935b5a..73d15a8 100644
--- a/keymint/aidl/default/android.hardware.keymint@1.0-service.xml
+++ b/security/keymint/aidl/default/android.hardware.security.keymint-service.xml
@@ -1,6 +1,6 @@
 <manifest version="1.0" type="device">
     <hal format="aidl">
-        <name>android.hardware.keymint</name>
+        <name>android.hardware.security.keymint</name>
         <fqname>IKeyMintDevice/default</fqname>
     </hal>
 </manifest>
diff --git a/keymint/aidl/default/service.cpp b/security/keymint/aidl/default/service.cpp
similarity index 68%
rename from keymint/aidl/default/service.cpp
rename to security/keymint/aidl/default/service.cpp
index ca5555e..a710535 100644
--- a/keymint/aidl/default/service.cpp
+++ b/security/keymint/aidl/default/service.cpp
@@ -14,30 +14,30 @@
  * limitations under the License.
  */
 
-#define LOG_TAG "android.hardware.keymint1-service"
+#define LOG_TAG "android.hardware.security.keymint-service"
 
 #include <android-base/logging.h>
 #include <android/binder_manager.h>
 #include <android/binder_process.h>
 
-#include <AndroidKeyMint1Device.h>
+#include <AndroidKeyMintDevice.h>
 #include <keymaster/soft_keymaster_logger.h>
 
-using aidl::android::hardware::keymint::SecurityLevel;
-using aidl::android::hardware::keymint::V1_0::AndroidKeyMint1Device;
+using aidl::android::hardware::security::keymint::AndroidKeyMintDevice;
+using aidl::android::hardware::security::keymint::SecurityLevel;
 
 int main() {
     // Zero threads seems like a useless pool, but below we'll join this thread to it, increasing
     // the pool size to 1.
     ABinderProcess_setThreadPoolMaxThreadCount(0);
-    std::shared_ptr<AndroidKeyMint1Device> km5 =
-            ndk::SharedRefBase::make<AndroidKeyMint1Device>(SecurityLevel::SOFTWARE);
+    std::shared_ptr<AndroidKeyMintDevice> keyMint =
+            ndk::SharedRefBase::make<AndroidKeyMintDevice>(SecurityLevel::SOFTWARE);
 
     keymaster::SoftKeymasterLogger logger;
-    const auto instanceName = std::string(AndroidKeyMint1Device::descriptor) + "/default";
+    const auto instanceName = std::string(AndroidKeyMintDevice::descriptor) + "/default";
     LOG(INFO) << "instance: " << instanceName;
     binder_status_t status =
-            AServiceManager_addService(km5->asBinder().get(), instanceName.c_str());
+            AServiceManager_addService(keyMint->asBinder().get(), instanceName.c_str());
     CHECK(status == STATUS_OK);
 
     ABinderProcess_joinThreadPool();
diff --git a/keymint/aidl/vts/functional/Android.bp b/security/keymint/aidl/vts/functional/Android.bp
similarity index 77%
rename from keymint/aidl/vts/functional/Android.bp
rename to security/keymint/aidl/vts/functional/Android.bp
index 9ee8239..ef7adb1 100644
--- a/keymint/aidl/vts/functional/Android.bp
+++ b/security/keymint/aidl/vts/functional/Android.bp
@@ -15,25 +15,25 @@
 //
 
 cc_test {
-    name: "VtsAidlKeyMintV1_0TargetTest",
+    name: "VtsAidlKeyMintTargetTest",
     defaults: [
         "VtsHalTargetTestDefaults",
         "use_libaidlvintf_gtest_helper_static",
     ],
     srcs: [
-        "keyMint1Test.cpp",
+        "KeyMintTest.cpp",
         "VerificationTokenTest.cpp",
     ],
     shared_libs: [
         "libbinder",
         "libcrypto",
-        "libkeymint1",
-        "libkeymintSupport",
+        "libkeymint",
+        "libkeymint_support",
     ],
     static_libs: [
-        "android.hardware.keymint-cpp",
-        "libcppbor",
-        "libkeyMint1VtsTestUtil",
+        "android.hardware.security.keymint-cpp",
+        "libcppbor_external",
+        "libkeymint_vts_test_utils",
     ],
     test_suites: [
         "general-tests",
@@ -42,7 +42,7 @@
 }
 
 cc_test_library {
-    name: "libkeyMint1VtsTestUtil",
+    name: "libkeymint_vts_test_utils",
     defaults: [
         "VtsHalTargetTestDefaults",
         "use_libaidlvintf_gtest_helper_static",
@@ -56,11 +56,11 @@
     shared_libs: [
         "libbinder",
         "libcrypto",
-        "libkeymint1",
-        "libkeymintSupport",
+        "libkeymint",
+        "libkeymint_support",
     ],
     static_libs: [
-        "android.hardware.keymint-cpp",
+        "android.hardware.security.keymint-cpp",
         "libcppbor",
     ],
 }
diff --git a/keymint/aidl/vts/functional/AndroidTest.xml b/security/keymint/aidl/vts/functional/AndroidTest.xml
similarity index 100%
rename from keymint/aidl/vts/functional/AndroidTest.xml
rename to security/keymint/aidl/vts/functional/AndroidTest.xml
diff --git a/keymint/aidl/vts/functional/KeyMintAidlTestBase.cpp b/security/keymint/aidl/vts/functional/KeyMintAidlTestBase.cpp
similarity index 98%
rename from keymint/aidl/vts/functional/KeyMintAidlTestBase.cpp
rename to security/keymint/aidl/vts/functional/KeyMintAidlTestBase.cpp
index 0546149..ea3a329 100644
--- a/keymint/aidl/vts/functional/KeyMintAidlTestBase.cpp
+++ b/security/keymint/aidl/vts/functional/KeyMintAidlTestBase.cpp
@@ -21,12 +21,10 @@
 
 #include <android-base/logging.h>
 
-#include <keymintSupport/key_param_output.h>
-#include <keymintSupport/keymint_utils.h>
+#include <keymint_support/key_param_output.h>
+#include <keymint_support/keymint_utils.h>
 
-namespace android {
-namespace hardware {
-namespace keymint {
+namespace android::hardware::security::keymint {
 
 using namespace std::literals::chrono_literals;
 using std::endl;
@@ -751,6 +749,5 @@
 }
 
 }  // namespace test
-}  // namespace keymint
-}  // namespace hardware
-}  // namespace android
+
+}  // namespace android::hardware::security::keymint
diff --git a/keymint/aidl/vts/functional/KeyMintAidlTestBase.h b/security/keymint/aidl/vts/functional/KeyMintAidlTestBase.h
similarity index 95%
rename from keymint/aidl/vts/functional/KeyMintAidlTestBase.h
rename to security/keymint/aidl/vts/functional/KeyMintAidlTestBase.h
index 2948c41..76effcf 100644
--- a/keymint/aidl/vts/functional/KeyMintAidlTestBase.h
+++ b/security/keymint/aidl/vts/functional/KeyMintAidlTestBase.h
@@ -21,18 +21,15 @@
 
 #include <aidl/Gtest.h>
 #include <aidl/Vintf.h>
-#include <android/hardware/keymint/ErrorCode.h>
-#include <android/hardware/keymint/IKeyMintDevice.h>
+#include <android/hardware/security/keymint/ErrorCode.h>
+#include <android/hardware/security/keymint/IKeyMintDevice.h>
 #include <binder/IServiceManager.h>
 #include <binder/ProcessState.h>
 #include <gtest/gtest.h>
 
-#include <keymintSupport/authorization_set.h>
+#include <keymint_support/authorization_set.h>
 
-namespace android {
-namespace hardware {
-namespace keymint {
-namespace test {
+namespace android::hardware::security::keymint::test {
 
 using ::android::sp;
 using binder::Status;
@@ -189,9 +186,6 @@
                              testing::ValuesIn(KeyMintAidlTestBase::build_params()), \
                              android::PrintInstanceNameToString)
 
-}  // namespace test
-}  // namespace keymint
-}  // namespace hardware
-}  // namespace android
+}  // namespace android::hardware::security::keymint::test
 
 #endif  // VTS_KEYMINT_AIDL_TEST_UTILS_H
diff --git a/keymint/aidl/vts/functional/keyMint1Test.cpp b/security/keymint/aidl/vts/functional/KeyMintTest.cpp
similarity index 99%
rename from keymint/aidl/vts/functional/keyMint1Test.cpp
rename to security/keymint/aidl/vts/functional/KeyMintTest.cpp
index c2fa2f8..f9423a2 100644
--- a/keymint/aidl/vts/functional/keyMint1Test.cpp
+++ b/security/keymint/aidl/vts/functional/KeyMintTest.cpp
@@ -26,36 +26,32 @@
 
 #include <cutils/properties.h>
 
-#include <android/hardware/keymint/KeyFormat.h>
+#include <android/hardware/security/keymint/KeyFormat.h>
 
-#include <keymintSupport/attestation_record.h>
-#include <keymintSupport/key_param_output.h>
-#include <keymintSupport/openssl_utils.h>
+#include <keymint_support/attestation_record.h>
+#include <keymint_support/key_param_output.h>
+#include <keymint_support/openssl_utils.h>
 
 #include "KeyMintAidlTestBase.h"
 
 static bool arm_deleteAllKeys = false;
 static bool dump_Attestations = false;
 
-using android::hardware::keymint::AuthorizationSet;
-using android::hardware::keymint::KeyCharacteristics;
-using android::hardware::keymint::KeyFormat;
+using android::hardware::security::keymint::AuthorizationSet;
+using android::hardware::security::keymint::KeyCharacteristics;
+using android::hardware::security::keymint::KeyFormat;
 
-namespace android {
-namespace hardware {
-
-namespace keymint {
+namespace 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 keymint
-}  // namespace hardware
-}  // namespace android
+
+}  // namespace android::hardware::security::keymint
 
 namespace std {
 
-using namespace android::hardware::keymint;
+using namespace android::hardware::security::keymint;
 
 template <>
 struct std::equal_to<KeyCharacteristics> {
@@ -77,10 +73,8 @@
 
 }  // namespace std
 
-namespace android {
-namespace hardware {
-namespace keymint {
-namespace test {
+namespace android::hardware::security::keymint::test {
+
 namespace {
 
 template <TagType tag_type, Tag tag, typename ValueT>
@@ -4046,10 +4040,7 @@
 
 INSTANTIATE_KEYMINT_AIDL_TEST(TransportLimitTest);
 
-}  // namespace test
-}  // namespace keymint
-}  // namespace hardware
-}  // namespace android
+}  // namespace android::hardware::security::keymint::test
 
 int main(int argc, char** argv) {
     ::testing::InitGoogleTest(&argc, argv);
@@ -4063,7 +4054,5 @@
             }
         }
     }
-    int status = RUN_ALL_TESTS();
-    ALOGI("Test result = %d", status);
-    return status;
+    return RUN_ALL_TESTS();
 }
diff --git a/keymint/aidl/vts/functional/VerificationTokenTest.cpp b/security/keymint/aidl/vts/functional/VerificationTokenTest.cpp
similarity index 97%
rename from keymint/aidl/vts/functional/VerificationTokenTest.cpp
rename to security/keymint/aidl/vts/functional/VerificationTokenTest.cpp
index bd0942b..6d3a34e 100644
--- a/keymint/aidl/vts/functional/VerificationTokenTest.cpp
+++ b/security/keymint/aidl/vts/functional/VerificationTokenTest.cpp
@@ -16,10 +16,7 @@
 
 #include "KeyMintAidlTestBase.h"
 
-namespace android {
-namespace hardware {
-namespace keymint {
-namespace test {
+namespace android::hardware::security::keymint::test {
 
 class VerificationTokenTest : public KeyMintAidlTestBase {
   protected:
@@ -168,7 +165,4 @@
 
 INSTANTIATE_KEYMINT_AIDL_TEST(VerificationTokenTest);
 
-}  // namespace test
-}  // namespace keymint
-}  // namespace hardware
-}  // namespace android
+}  // namespace android::hardware::security::keymint::test
diff --git a/keymint/support/Android.bp b/security/keymint/support/Android.bp
similarity index 92%
rename from keymint/support/Android.bp
rename to security/keymint/support/Android.bp
index 432416e..ddac92f 100644
--- a/keymint/support/Android.bp
+++ b/security/keymint/support/Android.bp
@@ -15,7 +15,7 @@
 //
 
 cc_library {
-    name: "libkeymintSupport",
+    name: "libkeymint_support",
     cflags: [
         "-Wall",
         "-Wextra",
@@ -31,7 +31,7 @@
         "include",
     ],
     shared_libs: [
-        "android.hardware.keymint-cpp",
+        "android.hardware.security.keymint-cpp",
         "libbase",
         "libcrypto",
         "libutils",
diff --git a/keymint/support/OWNERS b/security/keymint/support/OWNERS
similarity index 100%
rename from keymint/support/OWNERS
rename to security/keymint/support/OWNERS
diff --git a/keymint/support/attestation_record.cpp b/security/keymint/support/attestation_record.cpp
similarity index 97%
rename from keymint/support/attestation_record.cpp
rename to security/keymint/support/attestation_record.cpp
index e565974..afdb208 100644
--- a/keymint/support/attestation_record.cpp
+++ b/security/keymint/support/attestation_record.cpp
@@ -14,27 +14,26 @@
  * limitations under the License.
  */
 
-#include <keymintSupport/attestation_record.h>
+#include <keymint_support/attestation_record.h>
 
-#include <android/hardware/keymint/Tag.h>
-#include <android/hardware/keymint/TagType.h>
+#include <assert.h>
 
 #include <android-base/logging.h>
-#include <assert.h>
 
 #include <openssl/asn1t.h>
 #include <openssl/bn.h>
 #include <openssl/evp.h>
 #include <openssl/x509.h>
 
-#include <keymintSupport/authorization_set.h>
-#include <keymintSupport/openssl_utils.h>
+#include <android/hardware/security/keymint/Tag.h>
+#include <android/hardware/security/keymint/TagType.h>
+
+#include <keymint_support/authorization_set.h>
+#include <keymint_support/openssl_utils.h>
 
 #define AT __FILE__ ":" << __LINE__
 
-namespace android {
-namespace hardware {
-namespace keymint {
+namespace android::hardware::security::keymint {
 
 struct stack_st_ASN1_TYPE_Delete {
     void operator()(stack_st_ASN1_TYPE* p) { sk_ASN1_TYPE_free(p); }
@@ -382,6 +381,4 @@
     return ErrorCode::OK;  // KM_ERROR_OK;
 }
 
-}  // namespace keymint
-}  // namespace hardware
-}  // namespace android
+}  // namespace android::hardware::security::keymint
diff --git a/keymint/support/authorization_set.cpp b/security/keymint/support/authorization_set.cpp
similarity index 93%
rename from keymint/support/authorization_set.cpp
rename to security/keymint/support/authorization_set.cpp
index 9fc4e13..aa9638f 100644
--- a/keymint/support/authorization_set.cpp
+++ b/security/keymint/support/authorization_set.cpp
@@ -14,23 +14,21 @@
  * limitations under the License.
  */
 
-#include <keymintSupport/authorization_set.h>
+#include <keymint_support/authorization_set.h>
 
 #include <assert.h>
-
-#include <android-base/logging.h>
 #include <sstream>
 
-#include <android/hardware/keymint/Algorithm.h>
-#include <android/hardware/keymint/BlockMode.h>
-#include <android/hardware/keymint/Digest.h>
-#include <android/hardware/keymint/KeyParameter.h>
-#include <android/hardware/keymint/KeyPurpose.h>
-#include <android/hardware/keymint/TagType.h>
+#include <android-base/logging.h>
 
-namespace android {
-namespace hardware {
-namespace keymint {
+#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 {
 
 void AuthorizationSet::Sort() {
     std::sort(data_.begin(), data_.end());
@@ -220,10 +218,11 @@
 };
 
 template <TagType tag_type, Tag tag, typename... Tail>
-struct choose_serializer<android::hardware::keymint::TypedTag<tag_type, tag>, Tail...> {
+struct choose_serializer<android::hardware::security::keymint::TypedTag<tag_type, tag>, Tail...> {
     static OutStreams& serialize(OutStreams& out, const KeyParameter& param) {
         if (param.tag == tag) {
-            return android::hardware::keymint::serialize(TypedTag<tag_type, tag>(), out, param);
+            return android::hardware::security::keymint::serialize(TypedTag<tag_type, tag>(), out,
+                                                                   param);
         } else {
             return choose_serializer<Tail...>::serialize(out, param);
         }
@@ -329,7 +328,8 @@
 struct choose_deserializer<TypedTag<tag_type, tag>, Tail...> {
     static InStreams& deserialize(InStreams& in, KeyParameter* param) {
         if (param->tag == tag) {
-            return android::hardware::keymint::deserialize(TypedTag<tag_type, tag>(), in, param);
+            return android::hardware::security::keymint::deserialize(TypedTag<tag_type, tag>(), in,
+                                                                     param);
         } else {
             return choose_deserializer<Tail...>::deserialize(in, param);
         }
@@ -501,15 +501,14 @@
 }
 
 AuthorizationSetBuilder& AuthorizationSetBuilder::BlockMode(
-        std::initializer_list<android::hardware::keymint::BlockMode> blockModes) {
+        std::initializer_list<android::hardware::security::keymint::BlockMode> blockModes) {
     for (auto mode : blockModes) {
         push_back(TAG_BLOCK_MODE, mode);
     }
     return *this;
 }
 
-AuthorizationSetBuilder& AuthorizationSetBuilder::Digest(
-        std::vector<android::hardware::keymint::Digest> digests) {
+AuthorizationSetBuilder& AuthorizationSetBuilder::Digest(std::vector<keymint::Digest> digests) {
     for (auto digest : digests) {
         push_back(TAG_DIGEST, digest);
     }
@@ -524,6 +523,4 @@
     return *this;
 }
 
-}  // namespace keymint
-}  // namespace hardware
-}  // namespace android
+}  // namespace android::hardware::security::keymint
diff --git a/keymint/support/include/keymintSupport/attestation_record.h b/security/keymint/support/include/keymint_support/attestation_record.h
similarity index 84%
rename from keymint/support/include/keymintSupport/attestation_record.h
rename to security/keymint/support/include/keymint_support/attestation_record.h
index 7a69789..d71624c 100644
--- a/keymint/support/include/keymintSupport/attestation_record.h
+++ b/security/keymint/support/include/keymint_support/attestation_record.h
@@ -16,20 +16,14 @@
 
 #pragma once
 
-#include <android/hardware/keymint/ErrorCode.h>
-#include <android/hardware/keymint/IKeyMintDevice.h>
+#include <android/hardware/security/keymint/ErrorCode.h>
+#include <android/hardware/security/keymint/IKeyMintDevice.h>
 
-#include <keymintSupport/attestation_record.h>
-#include <keymintSupport/authorization_set.h>
-#include <keymintSupport/openssl_utils.h>
+#include <keymint_support/attestation_record.h>
+#include <keymint_support/authorization_set.h>
+#include <keymint_support/openssl_utils.h>
 
-namespace android {
-namespace hardware {
-namespace keymint {
-
-using android::hardware::keymint::KeyParameter;
-using android::hardware::keymint::Tag;
-using android::hardware::keymint::TAG_ALGORITHM;
+namespace android::hardware::security::keymint {
 
 class AuthorizationSet;
 
@@ -90,6 +84,4 @@
                               keymint_verified_boot_t* verified_boot_state, bool* device_locked,
                               std::vector<uint8_t>* verified_boot_hash);
 
-}  // namespace keymint
-}  // namespace hardware
-}  // namespace android
+}  // namespace android::hardware::security::keymint
diff --git a/keymint/support/include/keymintSupport/authorization_set.h b/security/keymint/support/include/keymint_support/authorization_set.h
similarity index 94%
rename from keymint/support/include/keymintSupport/authorization_set.h
rename to security/keymint/support/include/keymint_support/authorization_set.h
index 141426a..97e1022 100644
--- a/keymint/support/include/keymintSupport/authorization_set.h
+++ b/security/keymint/support/include/keymint_support/authorization_set.h
@@ -19,21 +19,14 @@
 
 #include <vector>
 
-#include <android/hardware/keymint/BlockMode.h>
-#include <android/hardware/keymint/Digest.h>
-#include <android/hardware/keymint/EcCurve.h>
-#include <android/hardware/keymint/PaddingMode.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/PaddingMode.h>
 
-#include <keymintSupport/keymint_tags.h>
+#include <keymint_support/keymint_tags.h>
 
-namespace android {
-namespace hardware {
-namespace keymint {
-
-using android::hardware::keymint::BlockMode;
-using android::hardware::keymint::Digest;
-using android::hardware::keymint::EcCurve;
-using android::hardware::keymint::PaddingMode;
+namespace android::hardware::security::keymint {
 
 using std::vector;
 
@@ -322,8 +315,6 @@
     }
 };
 
-}  // namespace keymint
-}  // namespace hardware
-}  // namespace android
+}  // namespace android::hardware::security::keymint
 
 #endif  // SYSTEM_SECURITY_KEYSTORE_KM4_AUTHORIZATION_SET_H_
diff --git a/keymint/support/include/keymintSupport/key_param_output.h b/security/keymint/support/include/keymint_support/key_param_output.h
similarity index 72%
rename from keymint/support/include/keymintSupport/key_param_output.h
rename to security/keymint/support/include/keymint_support/key_param_output.h
index a35a981..82c9689 100644
--- a/keymint/support/include/keymintSupport/key_param_output.h
+++ b/security/keymint/support/include/keymint_support/key_param_output.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2017 The Android Open Source Project
+ * Copyright (C) 2020 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -20,28 +20,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 "keymint_tags.h"
 
-#include <android/hardware/keymint/Algorithm.h>
-#include <android/hardware/keymint/BlockMode.h>
-#include <android/hardware/keymint/Digest.h>
-#include <android/hardware/keymint/EcCurve.h>
-#include <android/hardware/keymint/ErrorCode.h>
-#include <android/hardware/keymint/HardwareAuthenticatorType.h>
-#include <android/hardware/keymint/KeyCharacteristics.h>
-#include <android/hardware/keymint/KeyOrigin.h>
-#include <android/hardware/keymint/KeyParameter.h>
-#include <android/hardware/keymint/KeyPurpose.h>
-#include <android/hardware/keymint/PaddingMode.h>
-#include <android/hardware/keymint/SecurityLevel.h>
-#include <android/hardware/keymint/Tag.h>
-#include <android/hardware/keymint/TagType.h>
-
-namespace android {
-namespace hardware {
-namespace keymint {
-
-using namespace ::android::hardware::keymint;
+namespace android::hardware::security::keymint {
 
 inline ::std::ostream& operator<<(::std::ostream& os, Algorithm value) {
     return os << toString(value);
@@ -101,8 +97,6 @@
     return os << toString(tag);
 }
 
-}  // namespace keymint
-}  // namespace hardware
-}  // namespace android
+}  // namespace android::hardware::security::keymint
 
 #endif  // HARDWARE_INTERFACES_KEYMINT_SUPPORT_INCLUDE_KEY_PARAM_OUTPUT_H_
diff --git a/keymint/support/include/keymintSupport/keymint_tags.h b/security/keymint/support/include/keymint_support/keymint_tags.h
similarity index 80%
rename from keymint/support/include/keymintSupport/keymint_tags.h
rename to security/keymint/support/include/keymint_support/keymint_tags.h
index f1060a9..f23e4f2 100644
--- a/keymint/support/include/keymintSupport/keymint_tags.h
+++ b/security/keymint/support/include/keymint_support/keymint_tags.h
@@ -17,24 +17,20 @@
 #ifndef HARDWARE_INTERFACES_KEYMINT_SUPPORT_INCLUDE_KEYMINT_TAGS_H_
 #define HARDWARE_INTERFACES_KEYMINT_SUPPORT_INCLUDE_KEYMINT_TAGS_H_
 
-#include <android/hardware/keymint/Algorithm.h>
-#include <android/hardware/keymint/BlockMode.h>
-#include <android/hardware/keymint/Digest.h>
-#include <android/hardware/keymint/EcCurve.h>
-#include <android/hardware/keymint/HardwareAuthenticatorType.h>
-#include <android/hardware/keymint/KeyOrigin.h>
-#include <android/hardware/keymint/KeyParameter.h>
-#include <android/hardware/keymint/KeyPurpose.h>
-#include <android/hardware/keymint/PaddingMode.h>
-#include <android/hardware/keymint/SecurityLevel.h>
-#include <android/hardware/keymint/Tag.h>
-#include <android/hardware/keymint/TagType.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/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>
 
-namespace android::hardware::keymint {
-
-using android::hardware::keymint::KeyParameter;
-using android::hardware::keymint::Tag;
-using android::hardware::keymint::TagType;
+namespace android::hardware::security::keymint {
 
 // The following create the numeric values that KM_TAG_PADDING and KM_TAG_DIGEST used to have.  We
 // need these old values to be able to support old keys that use them.
@@ -337,78 +333,6 @@
     return accessTagValue(ttag, param);
 }
 
-}  // namespace android::hardware::keymint
-
-namespace std {
-
-using namespace android::hardware::keymint;
-
-// Aidl generates KeyParameter operator<, >, ==, != for cpp translation but not ndk
-// translations.  So we cannot straight forward overload these operators.
-// However we need our custom comparison for KeyParameters.  So we will
-// overload std::less, equal_to instead.
-template <>
-struct std::less<KeyParameter> {
-    bool operator()(const KeyParameter& a, const KeyParameter& b) const {
-        if (a.tag != b.tag) return a.tag < b.tag;
-        int retval;
-        switch (typeFromTag(a.tag)) {
-            case TagType::INVALID:
-            case TagType::BOOL:
-                return false;
-            case TagType::ENUM:
-            case TagType::ENUM_REP:
-            case TagType::UINT:
-            case TagType::UINT_REP:
-                return a.integer < b.integer;
-            case TagType::ULONG:
-            case TagType::ULONG_REP:
-            case TagType::DATE:
-                return a.longInteger < b.longInteger;
-            case TagType::BIGNUM:
-            case TagType::BYTES:
-                // Handle the empty cases.
-                if (a.blob.size() == 0) return b.blob.size() != 0;
-                if (b.blob.size() == 0) return false;
-                retval = memcmp(&a.blob[0], &b.blob[0], std::min(a.blob.size(), b.blob.size()));
-                // if one is the prefix of the other the longer wins
-                if (retval == 0) return a.blob.size() < b.blob.size();
-                // Otherwise a is less if a is less.
-                else
-                    return retval < 0;
-        }
-        return false;
-    }
-};
-
-template <>
-struct std::equal_to<KeyParameter> {
-    bool operator()(const KeyParameter& a, const KeyParameter& b) const {
-        if (a.tag != b.tag) {
-            return false;
-        }
-        switch (typeFromTag(a.tag)) {
-            case TagType::INVALID:
-            case TagType::BOOL:
-                return true;
-            case TagType::ENUM:
-            case TagType::ENUM_REP:
-            case TagType::UINT:
-            case TagType::UINT_REP:
-                return a.integer == b.integer;
-            case TagType::ULONG:
-            case TagType::ULONG_REP:
-            case TagType::DATE:
-                return a.longInteger == b.longInteger;
-            case TagType::BIGNUM:
-            case TagType::BYTES:
-                if (a.blob.size() != b.blob.size()) return false;
-                return a.blob.size() == 0 || memcmp(&a.blob[0], &b.blob[0], a.blob.size()) == 0;
-        }
-        return false;
-    }
-};
-
-}  // namespace std
+}  // namespace android::hardware::security::keymint
 
 #endif  // HARDWARE_INTERFACES_KEYMINT_SUPPORT_INCLUDE_KEYMINT_TAGS_H_
diff --git a/keymint/support/include/keymintSupport/keymint_utils.h b/security/keymint/support/include/keymint_support/keymint_utils.h
similarity index 88%
rename from keymint/support/include/keymintSupport/keymint_utils.h
rename to security/keymint/support/include/keymint_support/keymint_utils.h
index aa1e93b..fda1b6c 100644
--- a/keymint/support/include/keymintSupport/keymint_utils.h
+++ b/security/keymint/support/include/keymint_support/keymint_utils.h
@@ -19,11 +19,9 @@
 #ifndef HARDWARE_INTERFACES_KEYMINT_10_SUPPORT_KEYMINT_UTILS_H_
 #define HARDWARE_INTERFACES_KEYMINT_10_SUPPORT_KEYMINT_UTILS_H_
 
-#include <android/hardware/keymint/HardwareAuthToken.h>
+#include <android/hardware/security/keymint/HardwareAuthToken.h>
 
-namespace android {
-namespace hardware {
-namespace keymint {
+namespace android::hardware::security::keymint {
 
 using std::vector;
 
@@ -44,8 +42,6 @@
 uint32_t getOsVersion();
 uint32_t getOsPatchlevel();
 
-}  // namespace keymint
-}  // namespace hardware
-}  // namespace android
+}  // namespace android::hardware::security::keymint
 
 #endif  // HARDWARE_INTERFACES_KEYMINT_10_SUPPORT_KEYMINT_UTILS_H_
diff --git a/keymint/support/include/keymintSupport/openssl_utils.h b/security/keymint/support/include/keymint_support/openssl_utils.h
similarity index 75%
rename from keymint/support/include/keymintSupport/openssl_utils.h
rename to security/keymint/support/include/keymint_support/openssl_utils.h
index 39633ed..cb09968 100644
--- a/keymint/support/include/keymintSupport/openssl_utils.h
+++ b/security/keymint/support/include/keymint_support/openssl_utils.h
@@ -17,11 +17,13 @@
 #ifndef HARDWARE_INTERFACES_KEYMINT_1_0_SUPPORT_OPENSSL_UTILS_H_
 #define HARDWARE_INTERFACES_KEYMINT_1_0_SUPPORT_OPENSSL_UTILS_H_
 
-#include <android/hardware/keymint/Digest.h>
+#include <android/hardware/security/keymint/Digest.h>
 
 #include <openssl/evp.h>
 #include <openssl/x509.h>
 
+namespace android::hardware::security::keymint {
+
 template <typename T, void (*F)(T*)>
 struct UniquePtrDeleter {
     void operator()(T* p) const { F(p); }
@@ -40,24 +42,26 @@
 
 typedef std::unique_ptr<BIGNUM, UniquePtrDeleter<BIGNUM, BN_free>> BIGNUM_Ptr;
 
-inline const EVP_MD* openssl_digest(android::hardware::keymint::Digest digest) {
+inline const EVP_MD* openssl_digest(Digest digest) {
     switch (digest) {
-        case android::hardware::keymint::Digest::NONE:
+        case Digest::NONE:
             return nullptr;
-        case android::hardware::keymint::Digest::MD5:
+        case Digest::MD5:
             return EVP_md5();
-        case android::hardware::keymint::Digest::SHA1:
+        case Digest::SHA1:
             return EVP_sha1();
-        case android::hardware::keymint::Digest::SHA_2_224:
+        case Digest::SHA_2_224:
             return EVP_sha224();
-        case android::hardware::keymint::Digest::SHA_2_256:
+        case Digest::SHA_2_256:
             return EVP_sha256();
-        case android::hardware::keymint::Digest::SHA_2_384:
+        case Digest::SHA_2_384:
             return EVP_sha384();
-        case android::hardware::keymint::Digest::SHA_2_512:
+        case Digest::SHA_2_512:
             return EVP_sha512();
     }
     return nullptr;
 }
 
+}  // namespace android::hardware::security::keymint
+
 #endif  // HARDWARE_INTERFACES_KEYMINT_1_0_SUPPORT_OPENSSL_UTILS_H_
diff --git a/keymint/support/key_param_output.cpp b/security/keymint/support/key_param_output.cpp
similarity index 90%
rename from keymint/support/key_param_output.cpp
rename to security/keymint/support/key_param_output.cpp
index 6e33558..b699b22 100644
--- a/keymint/support/key_param_output.cpp
+++ b/security/keymint/support/key_param_output.cpp
@@ -14,15 +14,13 @@
  * limitations under the License.
  */
 
-#include <keymintSupport/key_param_output.h>
-
-#include <keymintSupport/keymint_tags.h>
+#include <keymint_support/key_param_output.h>
 
 #include <iomanip>
 
-namespace android {
-namespace hardware {
-namespace keymint {
+#include <keymint_support/keymint_tags.h>
+
+namespace android::hardware::security::keymint {
 
 using ::std::endl;
 using ::std::ostream;
@@ -71,6 +69,4 @@
     return os << "UNKNOWN TAG TYPE!";
 }
 
-}  // namespace keymint
-}  // namespace hardware
-}  // namespace android
+}  // namespace android::hardware::security::keymint
diff --git a/keymint/support/keymint_utils.cpp b/security/keymint/support/keymint_utils.cpp
similarity index 95%
rename from keymint/support/keymint_utils.cpp
rename to security/keymint/support/keymint_utils.cpp
index fd57cf5..cd4cca2 100644
--- a/keymint/support/keymint_utils.cpp
+++ b/security/keymint/support/keymint_utils.cpp
@@ -18,11 +18,11 @@
 
 #include <android-base/properties.h>
 #include <hardware/hw_auth_token.h>
-#include <keymintSupport/keymint_utils.h>
+#include <keymint_support/keymint_utils.h>
 
 #include <arpa/inet.h>
 
-namespace android::hardware::keymint {
+namespace android::hardware::security::keymint {
 
 namespace {
 
@@ -111,4 +111,4 @@
     return getOsPatchlevel(patchlevel.c_str());
 }
 
-}  // namespace android::hardware::keymint
+}  // namespace android::hardware::security::keymint
diff --git a/sensors/common/default/2.X/multihal/HalProxy.cpp b/sensors/common/default/2.X/multihal/HalProxy.cpp
index 650d7dc..f5fc066 100644
--- a/sensors/common/default/2.X/multihal/HalProxy.cpp
+++ b/sensors/common/default/2.X/multihal/HalProxy.cpp
@@ -695,6 +695,10 @@
                                                         int64_t timeoutStart /* = -1 */) {
     if (!mThreadsRun.load()) return;
     std::lock_guard<std::recursive_mutex> lockGuard(mWakelockMutex);
+    if (delta > mWakelockRefCount) {
+        ALOGE("Decrementing wakelock ref count by %zu when count is %zu",
+              delta, mWakelockRefCount);
+    }
     if (timeoutStart == -1) timeoutStart = mWakelockTimeoutResetTime;
     if (mWakelockRefCount == 0 || timeoutStart < mWakelockTimeoutResetTime) return;
     mWakelockRefCount -= std::min(mWakelockRefCount, delta);
diff --git a/sensors/common/default/2.X/multihal/ScopedWakelock.cpp b/sensors/common/default/2.X/multihal/ScopedWakelock.cpp
index bf2ad35..2a2baa2 100644
--- a/sensors/common/default/2.X/multihal/ScopedWakelock.cpp
+++ b/sensors/common/default/2.X/multihal/ScopedWakelock.cpp
@@ -28,6 +28,21 @@
             .count();
 }
 
+ScopedWakelock::ScopedWakelock(ScopedWakelock&& other) {
+    *this = std::move(other);
+}
+
+ScopedWakelock& ScopedWakelock::operator=(ScopedWakelock&& other) {
+    mRefCounter = other.mRefCounter;
+    mCreatedAtTimeNs = other.mCreatedAtTimeNs;
+    mLocked = other.mLocked;
+
+    other.mRefCounter = nullptr;
+    other.mCreatedAtTimeNs = 0;
+    other.mLocked = false;
+    return *this;
+}
+
 ScopedWakelock::ScopedWakelock(IScopedWakelockRefCounter* refCounter, bool locked)
     : mRefCounter(refCounter), mLocked(locked) {
     if (mLocked) {
diff --git a/sensors/common/default/2.X/multihal/include/V2_0/ScopedWakelock.h b/sensors/common/default/2.X/multihal/include/V2_0/ScopedWakelock.h
index 1cc5cd5..b3f398c 100644
--- a/sensors/common/default/2.X/multihal/include/V2_0/ScopedWakelock.h
+++ b/sensors/common/default/2.X/multihal/include/V2_0/ScopedWakelock.h
@@ -81,14 +81,15 @@
  */
 class ScopedWakelock {
   public:
-    ScopedWakelock(ScopedWakelock&&) = default;
-    ScopedWakelock& operator=(ScopedWakelock&&) = default;
+    ScopedWakelock(ScopedWakelock&& other);
+    ScopedWakelock& operator=(ScopedWakelock&& other);
     virtual ~ScopedWakelock();
 
     bool isLocked() const { return mLocked; }
 
   private:
     friend class HalProxyCallbackBase;
+    friend class ScopedWakelockTest;
     IScopedWakelockRefCounter* mRefCounter;
     int64_t mCreatedAtTimeNs;
     bool mLocked;
diff --git a/sensors/common/default/2.X/multihal/tests/Android.bp b/sensors/common/default/2.X/multihal/tests/Android.bp
index a15faed..1b60f4b 100644
--- a/sensors/common/default/2.X/multihal/tests/Android.bp
+++ b/sensors/common/default/2.X/multihal/tests/Android.bp
@@ -90,7 +90,10 @@
 
 cc_test {
     name: "android.hardware.sensors@2.X-halproxy-unit-tests",
-    srcs: ["HalProxy_test.cpp"],
+    srcs: [
+        "HalProxy_test.cpp",
+        "ScopedWakelock_test.cpp",
+    ],
     vendor: true,
     header_libs: [
         "android.hardware.sensors@2.X-shared-utils",
diff --git a/sensors/common/default/2.X/multihal/tests/ScopedWakelock_test.cpp b/sensors/common/default/2.X/multihal/tests/ScopedWakelock_test.cpp
new file mode 100644
index 0000000..133d9e8
--- /dev/null
+++ b/sensors/common/default/2.X/multihal/tests/ScopedWakelock_test.cpp
@@ -0,0 +1,110 @@
+//
+// Copyright (C) 2020 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include <gtest/gtest.h>
+
+#include "V2_0/ScopedWakelock.h"
+
+namespace android {
+namespace hardware {
+namespace sensors {
+namespace V2_0 {
+namespace implementation {
+
+class RefCounter : public IScopedWakelockRefCounter {
+  public:
+    size_t incCount = 0;
+    size_t decCount = 0;
+
+    bool incrementRefCountAndMaybeAcquireWakelock(size_t /* delta */,
+                                                  int64_t* /* timeoutStart */) override {
+        incCount++;
+        return true;
+    }
+
+    void decrementRefCountAndMaybeReleaseWakelock(size_t /* delta */,
+                                                  int64_t /* timeoutStart */) override {
+        decCount++;
+    }
+};
+
+class ScopedWakelockTest : public testing::Test {
+  public:
+    ScopedWakelock createScopedWakelock(bool locked) {
+        return ScopedWakelock(&mRefCounter, locked);
+    }
+
+    RefCounter mRefCounter;
+};
+
+TEST_F(ScopedWakelockTest, UnlockedAfterMoved) {
+    ScopedWakelock wakelock = createScopedWakelock(false /* locked */);
+
+    ScopedWakelock movedWakelock(std::move(wakelock));
+
+    EXPECT_FALSE(wakelock.isLocked());
+    EXPECT_FALSE(movedWakelock.isLocked());
+}
+
+TEST_F(ScopedWakelockTest, LockedAfterMoved) {
+    ScopedWakelock wakelock = createScopedWakelock(true /* locked */);
+
+    ScopedWakelock movedWakelock(std::move(wakelock));
+
+    EXPECT_FALSE(wakelock.isLocked());
+    EXPECT_TRUE(movedWakelock.isLocked());
+}
+
+TEST_F(ScopedWakelockTest, Locked) {
+    ScopedWakelock wakelock = createScopedWakelock(true /* locked */);
+
+    EXPECT_TRUE(wakelock.isLocked());
+}
+
+TEST_F(ScopedWakelockTest, Unlocked) {
+    ScopedWakelock wakelock = createScopedWakelock(false /* locked */);
+
+    EXPECT_FALSE(wakelock.isLocked());
+}
+
+TEST_F(ScopedWakelockTest, ScopedLocked) {
+    { createScopedWakelock(true /* locked */); }
+
+    EXPECT_EQ(mRefCounter.incCount, 1);
+    EXPECT_EQ(mRefCounter.decCount, 1);
+}
+
+TEST_F(ScopedWakelockTest, ScopedUnlockIsNoop) {
+    { createScopedWakelock(false /* locked */); }
+
+    EXPECT_EQ(mRefCounter.incCount, 0);
+    EXPECT_EQ(mRefCounter.decCount, 0);
+}
+
+TEST_F(ScopedWakelockTest, ScopedLockedMove) {
+    {
+        ScopedWakelock wakelock = createScopedWakelock(true /* locked */);
+        ScopedWakelock movedWakelock(std::move(wakelock));
+    }
+
+    EXPECT_EQ(mRefCounter.incCount, 1);
+    EXPECT_EQ(mRefCounter.decCount, 1);
+}
+
+}  // namespace implementation
+}  // namespace V2_0
+}  // namespace sensors
+}  // namespace hardware
+}  // namespace android
\ No newline at end of file
diff --git a/wifi/1.4/default/android.hardware.wifi@1.0-service-lazy.rc b/wifi/1.4/default/android.hardware.wifi@1.0-service-lazy.rc
index cf917b5..061689d 100644
--- a/wifi/1.4/default/android.hardware.wifi@1.0-service-lazy.rc
+++ b/wifi/1.4/default/android.hardware.wifi@1.0-service-lazy.rc
@@ -1,5 +1,9 @@
 service vendor.wifi_hal_legacy /vendor/bin/hw/android.hardware.wifi@1.0-service-lazy
     interface android.hardware.wifi@1.0::IWifi default
+    interface android.hardware.wifi@1.1::IWifi default
+    interface android.hardware.wifi@1.2::IWifi default
+    interface android.hardware.wifi@1.3::IWifi default
+    interface android.hardware.wifi@1.4::IWifi default
     oneshot
     disabled
     class hal
diff --git a/wifi/1.4/default/wifi_chip.cpp b/wifi/1.4/default/wifi_chip.cpp
index 8747e61..8cba464 100644
--- a/wifi/1.4/default/wifi_chip.cpp
+++ b/wifi/1.4/default/wifi_chip.cpp
@@ -624,6 +624,15 @@
 Return<void> WifiChip::debug(const hidl_handle& handle,
                              const hidl_vec<hidl_string>&) {
     if (handle != nullptr && handle->numFds >= 1) {
+        {
+            std::unique_lock<std::mutex> lk(lock_t);
+            for (const auto& item : ringbuffer_map_) {
+                forceDumpToDebugRingBufferInternal(item.first);
+            }
+            // unique_lock unlocked here
+        }
+        usleep(100 * 1000);  // sleep for 100 milliseconds to wait for
+                             // ringbuffer updates.
         int fd = handle->data[0];
         if (!writeRingbufferFilesInternal()) {
             LOG(ERROR) << "Error writing files to flash";
@@ -1120,6 +1129,9 @@
     legacy_hal::wifi_error legacy_status =
         legacy_hal_.lock()->deregisterRingBufferCallbackHandler(
             getFirstActiveWlanIfaceName());
+    if (legacy_status == legacy_hal::WIFI_SUCCESS) {
+        debug_ring_buffer_cb_registered_ = false;
+    }
     return createWifiStatusFromLegacyError(legacy_status);
 }
 
@@ -1335,7 +1347,7 @@
                     LOG(ERROR) << "Ringname " << name << " not found";
                     return;
                 }
-                // unlock
+                // unique_lock unlocked here
             }
         };
     legacy_hal::wifi_error legacy_status =
@@ -1637,7 +1649,7 @@
                 }
             }
         }
-        // unlock
+        // unique_lock unlocked here
     }
     return true;
 }
diff --git a/wifi/1.4/default/wifi_legacy_hal.cpp b/wifi/1.4/default/wifi_legacy_hal.cpp
index d7a5d6c..9e6b5a3 100644
--- a/wifi/1.4/default/wifi_legacy_hal.cpp
+++ b/wifi/1.4/default/wifi_legacy_hal.cpp
@@ -367,8 +367,8 @@
     }
     LOG(DEBUG) << "Waiting for the driver ready";
     wifi_error status = global_func_table_.wifi_wait_for_driver_ready();
-    if (status == WIFI_ERROR_TIMED_OUT) {
-        LOG(ERROR) << "Timed out awaiting driver ready";
+    if (status == WIFI_ERROR_TIMED_OUT || status == WIFI_ERROR_UNKNOWN) {
+        LOG(ERROR) << "Failed or timed out awaiting driver ready";
         return status;
     }
     property_set(kDriverPropName, "ok");
diff --git a/wifi/1.4/default/wifi_nan_iface.cpp b/wifi/1.4/default/wifi_nan_iface.cpp
index 5764d35..24ffb17 100644
--- a/wifi/1.4/default/wifi_nan_iface.cpp
+++ b/wifi/1.4/default/wifi_nan_iface.cpp
@@ -534,6 +534,9 @@
 }
 
 void WifiNanIface::invalidate() {
+    if (!isValid()) {
+        return;
+    }
     // send commands to HAL to actually disable and destroy interfaces
     legacy_hal_.lock()->nanDisableRequest(ifname_, 0xFFFF);
     legacy_hal_.lock()->nanDataInterfaceDelete(ifname_, 0xFFFE, "aware_data0");
diff --git a/wifi/supplicant/1.0/vts/functional/supplicant_hidl_test.cpp b/wifi/supplicant/1.0/vts/functional/supplicant_hidl_test.cpp
index 5730e50..ac39a24 100644
--- a/wifi/supplicant/1.0/vts/functional/supplicant_hidl_test.cpp
+++ b/wifi/supplicant/1.0/vts/functional/supplicant_hidl_test.cpp
@@ -40,16 +40,22 @@
     virtual void SetUp() override {
         wifi_instance_name_ = std::get<0>(GetParam());
         supplicant_instance_name_ = std::get<1>(GetParam());
+        isP2pOn_ =
+            testing::deviceSupportsFeature("android.hardware.wifi.direct");
+        // Stop Framework
+        std::system("/system/bin/stop");
         stopSupplicant(wifi_instance_name_);
         startSupplicantAndWaitForHidlService(wifi_instance_name_,
                                              supplicant_instance_name_);
-        isP2pOn_ =
-            testing::deviceSupportsFeature("android.hardware.wifi.direct");
         supplicant_ = getSupplicant(supplicant_instance_name_, isP2pOn_);
         ASSERT_NE(supplicant_.get(), nullptr);
     }
 
-    virtual void TearDown() override { stopSupplicant(wifi_instance_name_); }
+    virtual void TearDown() override {
+        stopSupplicant(wifi_instance_name_);
+        // Start Framework
+        std::system("/system/bin/start");
+    }
 
    protected:
     // ISupplicant object used for all tests in this fixture.
diff --git a/wifi/supplicant/1.0/vts/functional/supplicant_p2p_iface_hidl_test.cpp b/wifi/supplicant/1.0/vts/functional/supplicant_p2p_iface_hidl_test.cpp
index a404e15..616869b 100644
--- a/wifi/supplicant/1.0/vts/functional/supplicant_p2p_iface_hidl_test.cpp
+++ b/wifi/supplicant/1.0/vts/functional/supplicant_p2p_iface_hidl_test.cpp
@@ -77,11 +77,13 @@
     virtual void SetUp() override {
         wifi_instance_name_ = std::get<0>(GetParam());
         supplicant_instance_name_ = std::get<1>(GetParam());
+        isP2pOn_ =
+            testing::deviceSupportsFeature("android.hardware.wifi.direct");
+        // Stop Framework
+        std::system("/system/bin/stop");
         stopSupplicant(wifi_instance_name_);
         startSupplicantAndWaitForHidlService(wifi_instance_name_,
                                              supplicant_instance_name_);
-        isP2pOn_ =
-            testing::deviceSupportsFeature("android.hardware.wifi.direct");
         supplicant_ = getSupplicant(supplicant_instance_name_, isP2pOn_);
         EXPECT_TRUE(turnOnExcessiveLogging(supplicant_));
         p2p_iface_ = getSupplicantP2pIface(supplicant_);
@@ -91,7 +93,11 @@
         memcpy(peer_mac_addr_.data(), kTestPeerMacAddr, peer_mac_addr_.size());
     }
 
-    virtual void TearDown() override { stopSupplicant(wifi_instance_name_); }
+    virtual void TearDown() override {
+        stopSupplicant(wifi_instance_name_);
+        // Start Framework
+        std::system("/system/bin/start");
+    }
 
    protected:
     bool isP2pOn_ = false;
diff --git a/wifi/supplicant/1.0/vts/functional/supplicant_sta_iface_hidl_test.cpp b/wifi/supplicant/1.0/vts/functional/supplicant_sta_iface_hidl_test.cpp
index aa60bfa..e4fe52c 100644
--- a/wifi/supplicant/1.0/vts/functional/supplicant_sta_iface_hidl_test.cpp
+++ b/wifi/supplicant/1.0/vts/functional/supplicant_sta_iface_hidl_test.cpp
@@ -72,11 +72,13 @@
     virtual void SetUp() override {
         wifi_instance_name_ = std::get<0>(GetParam());
         supplicant_instance_name_ = std::get<1>(GetParam());
+        isP2pOn_ =
+            testing::deviceSupportsFeature("android.hardware.wifi.direct");
+        // Stop Framework
+        std::system("/system/bin/stop");
         stopSupplicant(wifi_instance_name_);
         startSupplicantAndWaitForHidlService(wifi_instance_name_,
                                              supplicant_instance_name_);
-        isP2pOn_ =
-            testing::deviceSupportsFeature("android.hardware.wifi.direct");
         supplicant_ = getSupplicant(supplicant_instance_name_, isP2pOn_);
         EXPECT_TRUE(turnOnExcessiveLogging(supplicant_));
         sta_iface_ = getSupplicantStaIface(supplicant_);
@@ -85,7 +87,11 @@
         memcpy(mac_addr_.data(), kTestMacAddr, mac_addr_.size());
     }
 
-    virtual void TearDown() override { stopSupplicant(wifi_instance_name_); }
+    virtual void TearDown() override {
+        stopSupplicant(wifi_instance_name_);
+        // Start Framework
+        std::system("/system/bin/start");
+    }
 
    protected:
     bool isP2pOn_ = false;
diff --git a/wifi/supplicant/1.0/vts/functional/supplicant_sta_network_hidl_test.cpp b/wifi/supplicant/1.0/vts/functional/supplicant_sta_network_hidl_test.cpp
index 7f8a066..7e93c5f 100644
--- a/wifi/supplicant/1.0/vts/functional/supplicant_sta_network_hidl_test.cpp
+++ b/wifi/supplicant/1.0/vts/functional/supplicant_sta_network_hidl_test.cpp
@@ -85,11 +85,13 @@
     virtual void SetUp() override {
         wifi_instance_name_ = std::get<0>(GetParam());
         supplicant_instance_name_ = std::get<1>(GetParam());
+        isP2pOn_ =
+            testing::deviceSupportsFeature("android.hardware.wifi.direct");
+        // Stop Framework
+        std::system("/system/bin/stop");
         stopSupplicant(wifi_instance_name_);
         startSupplicantAndWaitForHidlService(wifi_instance_name_,
                                              supplicant_instance_name_);
-        isP2pOn_ =
-            testing::deviceSupportsFeature("android.hardware.wifi.direct");
         supplicant_ = getSupplicant(supplicant_instance_name_, isP2pOn_);
         EXPECT_TRUE(turnOnExcessiveLogging(supplicant_));
         sta_network_ = createSupplicantStaNetwork(supplicant_);
@@ -103,7 +105,11 @@
         ssid_.assign(kTestSsidStr, kTestSsidStr + strlen(kTestSsidStr));
     }
 
-    virtual void TearDown() override { stopSupplicant(wifi_instance_name_); }
+    virtual void TearDown() override {
+        stopSupplicant(wifi_instance_name_);
+        // Start Framework
+        std::system("/system/bin/start");
+    }
 
    protected:
     void removeNetwork() {
diff --git a/wifi/supplicant/1.1/vts/functional/supplicant_hidl_test_utils_1_1.h b/wifi/supplicant/1.1/vts/functional/supplicant_hidl_test_utils_1_1.h
index 3629882..2104794 100644
--- a/wifi/supplicant/1.1/vts/functional/supplicant_hidl_test_utils_1_1.h
+++ b/wifi/supplicant/1.1/vts/functional/supplicant_hidl_test_utils_1_1.h
@@ -44,6 +44,8 @@
         supplicant_v1_1_instance_name_ = std::get<1>(GetParam());
         isP2pOn_ =
             testing::deviceSupportsFeature("android.hardware.wifi.direct");
+        // Stop Framework
+        std::system("/system/bin/stop");
         stopSupplicant(wifi_v1_0_instance_name_);
         startSupplicantAndWaitForHidlService(wifi_v1_0_instance_name_,
                                              supplicant_v1_1_instance_name_);
@@ -54,6 +56,8 @@
 
     virtual void TearDown() override {
         stopSupplicant(wifi_v1_0_instance_name_);
+        // Start Framework
+        std::system("/system/bin/start");
     }
 
    protected:
diff --git a/wifi/supplicant/1.2/vts/functional/supplicant_hidl_test_utils_1_2.h b/wifi/supplicant/1.2/vts/functional/supplicant_hidl_test_utils_1_2.h
index 5ecfdd4..2a432d0 100644
--- a/wifi/supplicant/1.2/vts/functional/supplicant_hidl_test_utils_1_2.h
+++ b/wifi/supplicant/1.2/vts/functional/supplicant_hidl_test_utils_1_2.h
@@ -50,6 +50,8 @@
         supplicant_v1_2_instance_name_ = std::get<1>(GetParam());
         isP2pOn_ =
             testing::deviceSupportsFeature("android.hardware.wifi.direct");
+        // Stop Framework
+        std::system("/system/bin/stop");
         stopSupplicant(wifi_v1_0_instance_name_);
         startSupplicantAndWaitForHidlService(wifi_v1_0_instance_name_,
                                              supplicant_v1_2_instance_name_);
@@ -61,6 +63,8 @@
 
     virtual void TearDown() override {
         stopSupplicant(wifi_v1_0_instance_name_);
+        // Start Framework
+        std::system("/system/bin/start");
     }
 
    protected:
diff --git a/wifi/supplicant/1.2/vts/functional/supplicant_p2p_iface_hidl_test.cpp b/wifi/supplicant/1.2/vts/functional/supplicant_p2p_iface_hidl_test.cpp
index 28f661c..75512d7 100644
--- a/wifi/supplicant/1.2/vts/functional/supplicant_p2p_iface_hidl_test.cpp
+++ b/wifi/supplicant/1.2/vts/functional/supplicant_p2p_iface_hidl_test.cpp
@@ -43,7 +43,7 @@
     virtual void SetUp() override {
         SupplicantHidlTestBase::SetUp();
         EXPECT_TRUE(turnOnExcessiveLogging(supplicant_));
-        if (!::testing::deviceSupportsFeature("android.hardware.wifi.direct")) {
+        if (!isP2pOn_) {
             GTEST_SKIP() << "Wi-Fi Direct is not supported, skip this test.";
         }
         p2p_iface_ = getSupplicantP2pIface_1_2(supplicant_);
diff --git a/wifi/supplicant/1.3/vts/functional/supplicant_sta_iface_hidl_test.cpp b/wifi/supplicant/1.3/vts/functional/supplicant_sta_iface_hidl_test.cpp
index 177b81e..504ccc4 100644
--- a/wifi/supplicant/1.3/vts/functional/supplicant_sta_iface_hidl_test.cpp
+++ b/wifi/supplicant/1.3/vts/functional/supplicant_sta_iface_hidl_test.cpp
@@ -63,6 +63,8 @@
         supplicant_v1_3_instance_name_ = std::get<1>(GetParam());
         isP2pOn_ =
             testing::deviceSupportsFeature("android.hardware.wifi.direct");
+        // Stop Framework
+        std::system("/system/bin/stop");
 
         stopSupplicant(wifi_v1_0_instance_name_);
         startSupplicantAndWaitForHidlService(wifi_v1_0_instance_name_,
@@ -76,6 +78,8 @@
 
     virtual void TearDown() override {
         stopSupplicant(wifi_v1_0_instance_name_);
+        // Start Framework
+        std::system("/system/bin/start");
     }
 
     int64_t pmkCacheExpirationTimeInSec;
diff --git a/wifi/supplicant/1.3/vts/functional/supplicant_sta_network_hidl_test.cpp b/wifi/supplicant/1.3/vts/functional/supplicant_sta_network_hidl_test.cpp
index de833c9..11c55a6 100644
--- a/wifi/supplicant/1.3/vts/functional/supplicant_sta_network_hidl_test.cpp
+++ b/wifi/supplicant/1.3/vts/functional/supplicant_sta_network_hidl_test.cpp
@@ -51,6 +51,8 @@
         supplicant_v1_3_instance_name_ = std::get<1>(GetParam());
         isP2pOn_ =
             testing::deviceSupportsFeature("android.hardware.wifi.direct");
+        // Stop Framework
+        std::system("/system/bin/stop");
 
         stopSupplicant(wifi_v1_0_instance_name_);
         startSupplicantAndWaitForHidlService(wifi_v1_0_instance_name_,
@@ -66,6 +68,8 @@
 
     virtual void TearDown() override {
         stopSupplicant(wifi_v1_0_instance_name_);
+        // Start Framework
+        std::system("/system/bin/start");
     }
 
    protected: