Merge "Add AndroidCarApiTest to presubmit."
diff --git a/audio/common/all-versions/default/service/Android.bp b/audio/common/all-versions/default/service/Android.bp
index 1bd6abe..9890be2 100644
--- a/audio/common/all-versions/default/service/Android.bp
+++ b/audio/common/all-versions/default/service/Android.bp
@@ -52,6 +52,7 @@
     shared_libs: [
         "libcutils",
         "libbinder",
+        "libbinder_ndk",
         "libhidlbase",
         "liblog",
         "libutils",
diff --git a/audio/common/all-versions/default/service/service.cpp b/audio/common/all-versions/default/service/service.cpp
index e26369f..3472af1 100644
--- a/audio/common/all-versions/default/service/service.cpp
+++ b/audio/common/all-versions/default/service/service.cpp
@@ -20,6 +20,7 @@
 #include <string>
 #include <vector>
 
+#include <android/binder_process.h>
 #include <binder/ProcessState.h>
 #include <cutils/properties.h>
 #include <hidl/HidlTransportSupport.h>
@@ -52,6 +53,9 @@
     // start a threadpool for vndbinder interactions
     ::android::ProcessState::self()->startThreadPool();
 
+    ABinderProcess_setThreadPoolMaxThreadCount(1);
+    ABinderProcess_startThreadPool();
+
     const int32_t defaultValue = -1;
     int32_t value =
         property_get_int32("persist.vendor.audio.service.hwbinder.size_kbyte", defaultValue);
diff --git a/bluetooth/audio/aidl/vts/VtsHalBluetoothAudioTargetTest.cpp b/bluetooth/audio/aidl/vts/VtsHalBluetoothAudioTargetTest.cpp
index 307403b..4454cc3 100644
--- a/bluetooth/audio/aidl/vts/VtsHalBluetoothAudioTargetTest.cpp
+++ b/bluetooth/audio/aidl/vts/VtsHalBluetoothAudioTargetTest.cpp
@@ -39,6 +39,7 @@
 using aidl::android::hardware::bluetooth::audio::AudioCapabilities;
 using aidl::android::hardware::bluetooth::audio::AudioConfiguration;
 using aidl::android::hardware::bluetooth::audio::BnBluetoothAudioPort;
+using aidl::android::hardware::bluetooth::audio::BroadcastCapability;
 using aidl::android::hardware::bluetooth::audio::ChannelMode;
 using aidl::android::hardware::bluetooth::audio::CodecCapabilities;
 using aidl::android::hardware::bluetooth::audio::CodecConfiguration;
@@ -51,6 +52,7 @@
 using aidl::android::hardware::bluetooth::audio::Lc3Configuration;
 using aidl::android::hardware::bluetooth::audio::LdacCapabilities;
 using aidl::android::hardware::bluetooth::audio::LdacConfiguration;
+using aidl::android::hardware::bluetooth::audio::LeAudioBroadcastConfiguration;
 using aidl::android::hardware::bluetooth::audio::
     LeAudioCodecCapabilitiesSetting;
 using aidl::android::hardware::bluetooth::audio::LeAudioCodecConfiguration;
@@ -417,7 +419,7 @@
 
   void GetA2dpOffloadCapabilityHelper(const CodecType& codec_type) {
     temp_codec_capabilities_ = nullptr;
-    for (auto codec_capability : temp_provider_capabilities_) {
+    for (auto& codec_capability : temp_provider_capabilities_) {
       auto& a2dp_capabilities =
           codec_capability.get<AudioCapabilities::a2dpCapabilities>();
       if (a2dp_capabilities.codecType != codec_type) {
@@ -983,7 +985,8 @@
               .channelMode = channel_mode,
               .dataIntervalUs = data_interval_us,
           };
-          bool is_codec_config_valid = IsPcmConfigSupported(pcm_config);
+          bool is_codec_config_valid =
+              IsPcmConfigSupported(pcm_config) && pcm_config.dataIntervalUs > 0;
           DataMQDesc mq_desc;
           auto aidl_retval = audio_provider_->startSession(
               audio_port_, AudioConfiguration(pcm_config), &mq_desc);
@@ -1001,7 +1004,7 @@
 }
 
 /**
- * openProvider LE_AUDIO_SOFTWARE_DECODED_DATAPATH
+ * openProvider LE_AUDIO_SOFTWARE_DECODING_DATAPATH
  */
 class BluetoothAudioProviderLeAudioInputSoftwareAidl
     : public BluetoothAudioProviderFactoryAidl {
@@ -1031,7 +1034,7 @@
 
 /**
  * Test whether each provider of type
- * SessionType::LE_AUDIO_SOFTWARE_DECODED_DATAPATH can be started and
+ * SessionType::LE_AUDIO_SOFTWARE_DECODING_DATAPATH can be started and
  * stopped
  */
 TEST_P(BluetoothAudioProviderLeAudioInputSoftwareAidl,
@@ -1039,7 +1042,7 @@
 
 /**
  * Test whether each provider of type
- * SessionType::LE_AUDIO_SOFTWARE_DECODED_DATAPATH can be started and
+ * SessionType::LE_AUDIO_SOFTWARE_DECODING_DATAPATH can be started and
  * stopped with different PCM config
  */
 TEST_P(BluetoothAudioProviderLeAudioInputSoftwareAidl,
@@ -1054,7 +1057,8 @@
               .channelMode = channel_mode,
               .dataIntervalUs = data_interval_us,
           };
-          bool is_codec_config_valid = IsPcmConfigSupported(pcm_config);
+          bool is_codec_config_valid =
+              IsPcmConfigSupported(pcm_config) && pcm_config.dataIntervalUs > 0;
           DataMQDesc mq_desc;
           auto aidl_retval = audio_provider_->startSession(
               audio_port_, AudioConfiguration(pcm_config), &mq_desc);
@@ -1072,7 +1076,7 @@
 }
 
 /**
- * openProvider LE_AUDIO_HARDWARE_OFFLOAD_DECODED_DATAPATH
+ * openProvider LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH
  */
 class BluetoothAudioProviderLeAudioOutputHardwareAidl
     : public BluetoothAudioProviderFactoryAidl {
@@ -1395,7 +1399,8 @@
               .channelMode = channel_mode,
               .dataIntervalUs = data_interval_us,
           };
-          bool is_codec_config_valid = IsPcmConfigSupported(pcm_config);
+          bool is_codec_config_valid =
+              IsPcmConfigSupported(pcm_config) && pcm_config.dataIntervalUs > 0;
           DataMQDesc mq_desc;
           auto aidl_retval = audio_provider_->startSession(
               audio_port_, AudioConfiguration(pcm_config), &mq_desc);
@@ -1412,6 +1417,164 @@
   }
 }
 
+/**
+ * openProvider LE_AUDIO_BROADCAST_HARDWARE_OFFLOAD_ENCODING_DATAPATH
+ */
+class BluetoothAudioProviderLeAudioBroadcastHardwareAidl
+    : public BluetoothAudioProviderFactoryAidl {
+ public:
+  virtual void SetUp() override {
+    BluetoothAudioProviderFactoryAidl::SetUp();
+    GetProviderCapabilitiesHelper(
+        SessionType::LE_AUDIO_BROADCAST_HARDWARE_OFFLOAD_ENCODING_DATAPATH);
+    OpenProviderHelper(
+        SessionType::LE_AUDIO_BROADCAST_HARDWARE_OFFLOAD_ENCODING_DATAPATH);
+    ASSERT_TRUE(temp_provider_capabilities_.empty() ||
+                audio_provider_ != nullptr);
+  }
+
+  virtual void TearDown() override {
+    audio_port_ = nullptr;
+    audio_provider_ = nullptr;
+    BluetoothAudioProviderFactoryAidl::TearDown();
+  }
+
+  bool IsBroadcastOffloadSupported() {
+    for (auto& capability : temp_provider_capabilities_) {
+      if (capability.getTag() != AudioCapabilities::leAudioCapabilities) {
+        continue;
+      }
+      auto& le_audio_capability =
+          capability.get<AudioCapabilities::leAudioCapabilities>();
+      if (le_audio_capability.broadcastCapability.codecType !=
+          CodecType::UNKNOWN)
+        return true;
+    }
+    return false;
+  }
+
+  std::vector<Lc3Configuration> GetBroadcastLc3SupportedList(bool supported) {
+    std::vector<Lc3Configuration> le_audio_codec_configs;
+    if (!supported) {
+      Lc3Configuration lc3_config{.samplingFrequencyHz = 0, .pcmBitDepth = 0};
+      le_audio_codec_configs.push_back(lc3_config);
+      return le_audio_codec_configs;
+    }
+
+    // There might be more than one LeAudioCodecCapabilitiesSetting
+    std::vector<Lc3Capabilities> lc3_capabilities;
+    for (auto& capability : temp_provider_capabilities_) {
+      if (capability.getTag() != AudioCapabilities::leAudioCapabilities) {
+        continue;
+      }
+      auto& le_audio_capability =
+          capability.get<AudioCapabilities::leAudioCapabilities>();
+      auto& broadcast_capability = le_audio_capability.broadcastCapability;
+      if (broadcast_capability.codecType != CodecType::LC3) {
+        continue;
+      }
+      auto& lc3_capability = broadcast_capability.leAudioCodecCapabilities.get<
+          BroadcastCapability::LeAudioCodecCapabilities::lc3Capabilities>();
+      for (int idx = 0; idx < lc3_capability->size(); idx++)
+        lc3_capabilities.push_back(*lc3_capability->at(idx));
+    }
+
+    // Combine those parameters into one list of LeAudioCodecConfiguration
+    // This seems horrible, but usually each Lc3Capability only contains a
+    // single Lc3Configuration, which means every array has a length of 1.
+    for (auto& lc3_capability : lc3_capabilities) {
+      for (int32_t samplingFrequencyHz : lc3_capability.samplingFrequencyHz) {
+        for (int32_t frameDurationUs : lc3_capability.frameDurationUs) {
+          for (int32_t octetsPerFrame : lc3_capability.octetsPerFrame) {
+            Lc3Configuration lc3_config = {
+                .samplingFrequencyHz = samplingFrequencyHz,
+                .frameDurationUs = frameDurationUs,
+                .octetsPerFrame = octetsPerFrame,
+            };
+            le_audio_codec_configs.push_back(lc3_config);
+          }
+        }
+      }
+    }
+
+    return le_audio_codec_configs;
+  }
+
+  LeAudioCodecCapabilitiesSetting temp_le_audio_capabilities_;
+};
+
+/**
+ * Test whether each provider of type
+ * SessionType::LE_AUDIO_BROADCAST_HARDWARE_OFFLOAD_ENCODING_DATAPATH can be
+ * started and stopped
+ */
+TEST_P(BluetoothAudioProviderLeAudioBroadcastHardwareAidl,
+       OpenLeAudioOutputHardwareProvider) {}
+
+/**
+ * Test whether each provider of type
+ * SessionType::LE_AUDIO_BROADCAST_HARDWARE_OFFLOAD_ENCODING_DATAPATH can be
+ * started and stopped with broadcast hardware encoding config
+ */
+TEST_P(BluetoothAudioProviderLeAudioBroadcastHardwareAidl,
+       StartAndEndLeAudioBroadcastSessionWithPossibleBroadcastConfig) {
+  if (!IsBroadcastOffloadSupported()) {
+    return;
+  }
+
+  auto lc3_codec_configs = GetBroadcastLc3SupportedList(true /* supported */);
+  LeAudioBroadcastConfiguration le_audio_broadcast_config = {
+      .codecType = CodecType::LC3,
+      .streamMap = {},
+  };
+
+  for (auto& lc3_config : lc3_codec_configs) {
+    le_audio_broadcast_config.streamMap[0]
+        .leAudioCodecConfig.set<LeAudioCodecConfiguration::lc3Config>(
+            lc3_config);
+    DataMQDesc mq_desc;
+    auto aidl_retval = audio_provider_->startSession(
+        audio_port_, AudioConfiguration(le_audio_broadcast_config), &mq_desc);
+
+    ASSERT_TRUE(aidl_retval.isOk());
+    EXPECT_TRUE(audio_provider_->endSession().isOk());
+  }
+}
+
+/**
+ * Test whether each provider of type
+ * SessionType::LE_AUDIO_BROADCAST_HARDWARE_OFFLOAD_ENCODING_DATAPATH can be
+ * started and stopped with Broadcast hardware encoding config
+ *
+ * Disabled since offload codec checking is not ready
+ */
+TEST_P(
+    BluetoothAudioProviderLeAudioBroadcastHardwareAidl,
+    DISABLED_StartAndEndLeAudioBroadcastSessionWithInvalidAudioConfiguration) {
+  if (!IsBroadcastOffloadSupported()) {
+    return;
+  }
+
+  auto lc3_codec_configs = GetBroadcastLc3SupportedList(false /* supported */);
+  LeAudioBroadcastConfiguration le_audio_broadcast_config = {
+      .codecType = CodecType::LC3,
+      .streamMap = {},
+  };
+
+  for (auto& lc3_config : lc3_codec_configs) {
+    le_audio_broadcast_config.streamMap[0]
+        .leAudioCodecConfig.set<LeAudioCodecConfiguration::lc3Config>(
+            lc3_config);
+    DataMQDesc mq_desc;
+    auto aidl_retval = audio_provider_->startSession(
+        audio_port_, AudioConfiguration(le_audio_broadcast_config), &mq_desc);
+
+    // AIDL call should fail on invalid codec
+    ASSERT_FALSE(aidl_retval.isOk());
+    EXPECT_TRUE(audio_provider_->endSession().isOk());
+  }
+}
+
 GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(
     BluetoothAudioProviderFactoryAidl);
 INSTANTIATE_TEST_SUITE_P(PerInstance, BluetoothAudioProviderFactoryAidl,
@@ -1481,14 +1644,13 @@
                              IBluetoothAudioProviderFactory::descriptor)),
                          android::PrintInstanceNameToString);
 
-// TODO(219668925): Add LE Audio Broadcast VTS
-// GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(
-//     BluetoothAudioProviderLeAudioBroadcastHardwareAidl);
-// INSTANTIATE_TEST_SUITE_P(PerInstance,
-//                          BluetoothAudioProviderLeAudioBroadcastHardwareAidl,
-//                          testing::ValuesIn(android::getAidlHalInstanceNames(
-//                              IBluetoothAudioProviderFactory::descriptor)),
-//                          android::PrintInstanceNameToString);
+GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(
+    BluetoothAudioProviderLeAudioBroadcastHardwareAidl);
+INSTANTIATE_TEST_SUITE_P(PerInstance,
+                         BluetoothAudioProviderLeAudioBroadcastHardwareAidl,
+                         testing::ValuesIn(android::getAidlHalInstanceNames(
+                             IBluetoothAudioProviderFactory::descriptor)),
+                         android::PrintInstanceNameToString);
 
 int main(int argc, char** argv) {
   ::testing::InitGoogleTest(&argc, argv);
diff --git a/bluetooth/audio/utils/aidl_session/BluetoothAudioCodecs.cpp b/bluetooth/audio/utils/aidl_session/BluetoothAudioCodecs.cpp
index a6fd798..8fd1ab5 100644
--- a/bluetooth/audio/utils/aidl_session/BluetoothAudioCodecs.cpp
+++ b/bluetooth/audio/utils/aidl_session/BluetoothAudioCodecs.cpp
@@ -307,7 +307,9 @@
   if (session_type !=
           SessionType::LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH &&
       session_type !=
-          SessionType::LE_AUDIO_HARDWARE_OFFLOAD_DECODING_DATAPATH) {
+          SessionType::LE_AUDIO_HARDWARE_OFFLOAD_DECODING_DATAPATH &&
+      session_type !=
+          SessionType::LE_AUDIO_BROADCAST_HARDWARE_OFFLOAD_ENCODING_DATAPATH) {
     return false;
   }
   return true;
@@ -451,7 +453,9 @@
   if (session_type !=
           SessionType::LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH &&
       session_type !=
-          SessionType::LE_AUDIO_HARDWARE_OFFLOAD_DECODING_DATAPATH) {
+          SessionType::LE_AUDIO_HARDWARE_OFFLOAD_DECODING_DATAPATH &&
+      session_type !=
+          SessionType::LE_AUDIO_BROADCAST_HARDWARE_OFFLOAD_ENCODING_DATAPATH) {
     return std::vector<LeAudioCodecCapabilitiesSetting>(0);
   }
 
diff --git a/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp b/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp
index 3254cf2..7e5e8b2 100644
--- a/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp
+++ b/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp
@@ -171,6 +171,27 @@
     int32_t format;
 };
 
+struct RecordingRateSizePair {
+    int32_t recordingRate;
+    int32_t width;
+    int32_t height;
+
+    bool operator==(const RecordingRateSizePair &p) const{
+        return p.recordingRate == recordingRate &&
+                p.width == width &&
+                p.height == height;
+    }
+};
+
+struct RecordingRateSizePairHasher {
+    size_t operator()(const RecordingRateSizePair& p) const {
+        std::size_t p1 = std::hash<int32_t>()(p.recordingRate);
+        std::size_t p2 = std::hash<int32_t>()(p.width);
+        std::size_t p3 = std::hash<int32_t>()(p.height);
+        return p1 ^ p2 ^ p3;
+    }
+};
+
 struct AvailableZSLInputOutput {
     int32_t inputFormat;
     int32_t outputFormat;
@@ -4540,6 +4561,39 @@
         rc = pickConstrainedModeSize(staticMeta, hfrStream);
         ASSERT_EQ(Status::OK, rc);
 
+        // Check that HAL does not advertise multiple preview rates
+        // for the same recording rate and size.
+        camera_metadata_ro_entry entry;
+
+        std::unordered_map<RecordingRateSizePair, int32_t, RecordingRateSizePairHasher> fpsRangeMap;
+
+        auto retCode = find_camera_metadata_ro_entry(staticMeta,
+                ANDROID_CONTROL_AVAILABLE_HIGH_SPEED_VIDEO_CONFIGURATIONS, &entry);
+        ASSERT_EQ(retCode, 0);
+        ASSERT_GT(entry.count, 0);
+
+        for (size_t i = 0; i < entry.count; i+=5) {
+            RecordingRateSizePair recordingRateSizePair;
+            recordingRateSizePair.width = entry.data.i32[i];
+            recordingRateSizePair.height = entry.data.i32[i+1];
+
+            int32_t previewFps = entry.data.i32[i+2];
+            int32_t recordingFps = entry.data.i32[i+3];
+            recordingRateSizePair.recordingRate = recordingFps;
+
+            if (recordingFps != previewFps) {
+                auto it = fpsRangeMap.find(recordingRateSizePair);
+                if (it == fpsRangeMap.end()) {
+                    fpsRangeMap.insert(std::make_pair(recordingRateSizePair,previewFps));
+                    ALOGV("Added RecordingRateSizePair:%d , %d, %d PreviewRate: %d",
+                            recordingFps, recordingRateSizePair.width, recordingRateSizePair.height,
+                            previewFps);
+                } else {
+                    ASSERT_EQ(previewFps, it->second);
+                }
+            }
+        }
+
         int32_t streamId = 0;
         uint32_t streamConfigCounter = 0;
         V3_2::Stream stream = {streamId,
diff --git a/radio/aidl/vts/radio_voice_test.cpp b/radio/aidl/vts/radio_voice_test.cpp
index eec28b1..249ee63 100644
--- a/radio/aidl/vts/radio_voice_test.cpp
+++ b/radio/aidl/vts/radio_voice_test.cpp
@@ -943,3 +943,37 @@
     }
     LOG(DEBUG) << "cancelPendingUssd finished";
 }
+
+/*
+ * Test IRadioVoice.isVoNrEnabled() for the response returned.
+ */
+TEST_P(RadioVoiceTest, isVoNrEnabled) {
+    LOG(DEBUG) << "isVoNrEnabled";
+    serial = GetRandomSerialNumber();
+
+    radio_voice->isVoNrEnabled(serial);
+    EXPECT_EQ(std::cv_status::no_timeout, wait());
+    EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_voice->rspInfo.type);
+    EXPECT_EQ(serial, radioRsp_voice->rspInfo.serial);
+
+    ASSERT_TRUE(CheckAnyOfErrors(radioRsp_voice->rspInfo.error,
+                                 {RadioError::REQUEST_NOT_SUPPORTED, RadioError::NONE}));
+    LOG(DEBUG) << "isVoNrEnabled finished";
+}
+
+/*
+ * Test IRadioVoice.setVoNrEnabled() for the response returned.
+ */
+TEST_P(RadioVoiceTest, setVoNrEnabled) {
+    LOG(DEBUG) << "setVoNrEnabled";
+    serial = GetRandomSerialNumber();
+
+    radio_voice->setVoNrEnabled(serial, true);
+    EXPECT_EQ(std::cv_status::no_timeout, wait());
+    EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_voice->rspInfo.type);
+    EXPECT_EQ(serial, radioRsp_voice->rspInfo.serial);
+
+    ASSERT_TRUE(CheckAnyOfErrors(radioRsp_voice->rspInfo.error,
+                                 {RadioError::REQUEST_NOT_SUPPORTED, RadioError::NONE}));
+    LOG(DEBUG) << "setVoNrEnabled finished";
+}
diff --git a/security/keymint/aidl/vts/functional/AttestKeyTest.cpp b/security/keymint/aidl/vts/functional/AttestKeyTest.cpp
index 727c6b7..8a26b3c 100644
--- a/security/keymint/aidl/vts/functional/AttestKeyTest.cpp
+++ b/security/keymint/aidl/vts/functional/AttestKeyTest.cpp
@@ -219,18 +219,22 @@
     AttestationKey attest_key;
     vector<KeyCharacteristics> attest_key_characteristics;
     vector<Certificate> attest_key_cert_chain;
-    ASSERT_EQ(ErrorCode::OK,
-              GenerateKey(AuthorizationSetBuilder()
-                                  .RsaKey(2048, 65537)
-                                  .AttestKey()
-                                  .AttestationChallenge(challenge)
-                                  .AttestationApplicationId(app_id)
-                                  .Authorization(TAG_CERTIFICATE_SERIAL, serial_blob)
-                                  .Authorization(TAG_CERTIFICATE_SUBJECT, subject_der)
-                                  .Authorization(TAG_NO_AUTH_REQUIRED)
-                                  .SetDefaultValidity(),
-                          {} /* attestation signing key */, &attest_key.keyBlob,
-                          &attest_key_characteristics, &attest_key_cert_chain));
+    auto result = GenerateKey(AuthorizationSetBuilder()
+                                      .RsaKey(2048, 65537)
+                                      .AttestKey()
+                                      .AttestationChallenge(challenge)
+                                      .AttestationApplicationId(app_id)
+                                      .Authorization(TAG_CERTIFICATE_SERIAL, serial_blob)
+                                      .Authorization(TAG_CERTIFICATE_SUBJECT, subject_der)
+                                      .Authorization(TAG_NO_AUTH_REQUIRED)
+                                      .SetDefaultValidity(),
+                              {} /* attestation signing key */, &attest_key.keyBlob,
+                              &attest_key_characteristics, &attest_key_cert_chain);
+    // Strongbox may not support factory provisioned attestation key.
+    if (SecLevel() == SecurityLevel::STRONGBOX) {
+        if (result == ErrorCode::ATTESTATION_KEYS_NOT_PROVISIONED) return;
+    }
+    ASSERT_EQ(ErrorCode::OK, result);
 
     EXPECT_GT(attest_key_cert_chain.size(), 1);
     verify_subject_and_serial(attest_key_cert_chain[0], serial_int, subject, false);
@@ -319,18 +323,22 @@
             attest_key_opt = attest_key;
         }
 
-        EXPECT_EQ(ErrorCode::OK,
-                  GenerateKey(AuthorizationSetBuilder()
-                                      .RsaKey(2048, 65537)
-                                      .AttestKey()
-                                      .AttestationChallenge("foo")
-                                      .AttestationApplicationId("bar")
-                                      .Authorization(TAG_NO_AUTH_REQUIRED)
-                                      .Authorization(TAG_CERTIFICATE_SERIAL, serial_blob)
-                                      .Authorization(TAG_CERTIFICATE_SUBJECT, subject_der)
-                                      .SetDefaultValidity(),
-                              attest_key_opt, &key_blob_list[i], &attested_key_characteristics,
-                              &cert_chain_list[i]));
+        auto result = GenerateKey(AuthorizationSetBuilder()
+                                          .RsaKey(2048, 65537)
+                                          .AttestKey()
+                                          .AttestationChallenge("foo")
+                                          .AttestationApplicationId("bar")
+                                          .Authorization(TAG_NO_AUTH_REQUIRED)
+                                          .Authorization(TAG_CERTIFICATE_SERIAL, serial_blob)
+                                          .Authorization(TAG_CERTIFICATE_SUBJECT, subject_der)
+                                          .SetDefaultValidity(),
+                                  attest_key_opt, &key_blob_list[i], &attested_key_characteristics,
+                                  &cert_chain_list[i]);
+        // Strongbox may not support factory provisioned attestation key.
+        if (SecLevel() == SecurityLevel::STRONGBOX) {
+            if (result == ErrorCode::ATTESTATION_KEYS_NOT_PROVISIONED) return;
+        }
+        ASSERT_EQ(ErrorCode::OK, result);
 
         AuthorizationSet hw_enforced = HwEnforcedAuthorizations(attested_key_characteristics);
         AuthorizationSet sw_enforced = SwEnforcedAuthorizations(attested_key_characteristics);
@@ -392,18 +400,22 @@
             attest_key_opt = attest_key;
         }
 
-        EXPECT_EQ(ErrorCode::OK,
-                  GenerateKey(AuthorizationSetBuilder()
-                                      .EcdsaKey(EcCurve::P_256)
-                                      .AttestKey()
-                                      .AttestationChallenge("foo")
-                                      .AttestationApplicationId("bar")
-                                      .Authorization(TAG_CERTIFICATE_SERIAL, serial_blob)
-                                      .Authorization(TAG_CERTIFICATE_SUBJECT, subject_der)
-                                      .Authorization(TAG_NO_AUTH_REQUIRED)
-                                      .SetDefaultValidity(),
-                              attest_key_opt, &key_blob_list[i], &attested_key_characteristics,
-                              &cert_chain_list[i]));
+        auto result = GenerateKey(AuthorizationSetBuilder()
+                                          .EcdsaKey(EcCurve::P_256)
+                                          .AttestKey()
+                                          .AttestationChallenge("foo")
+                                          .AttestationApplicationId("bar")
+                                          .Authorization(TAG_CERTIFICATE_SERIAL, serial_blob)
+                                          .Authorization(TAG_CERTIFICATE_SUBJECT, subject_der)
+                                          .Authorization(TAG_NO_AUTH_REQUIRED)
+                                          .SetDefaultValidity(),
+                                  attest_key_opt, &key_blob_list[i], &attested_key_characteristics,
+                                  &cert_chain_list[i]);
+        // Strongbox may not support factory provisioned attestation key.
+        if (SecLevel() == SecurityLevel::STRONGBOX) {
+            if (result == ErrorCode::ATTESTATION_KEYS_NOT_PROVISIONED) return;
+        }
+        ASSERT_EQ(ErrorCode::OK, result);
 
         AuthorizationSet hw_enforced = HwEnforcedAuthorizations(attested_key_characteristics);
         AuthorizationSet sw_enforced = SwEnforcedAuthorizations(attested_key_characteristics);
@@ -484,34 +496,37 @@
             attest_key.keyBlob = key_blob_list[i - 1];
             attest_key_opt = attest_key;
         }
-
+        ErrorCode result;
         if ((i & 0x1) == 1) {
-            EXPECT_EQ(ErrorCode::OK,
-                      GenerateKey(AuthorizationSetBuilder()
-                                          .EcdsaKey(EcCurve::P_256)
-                                          .AttestKey()
-                                          .AttestationChallenge("foo")
-                                          .AttestationApplicationId("bar")
-                                          .Authorization(TAG_CERTIFICATE_SERIAL, serial_blob)
-                                          .Authorization(TAG_CERTIFICATE_SUBJECT, subject_der)
-                                          .Authorization(TAG_NO_AUTH_REQUIRED)
-                                          .SetDefaultValidity(),
-                                  attest_key_opt, &key_blob_list[i], &attested_key_characteristics,
-                                  &cert_chain_list[i]));
+            result = GenerateKey(AuthorizationSetBuilder()
+                                         .EcdsaKey(EcCurve::P_256)
+                                         .AttestKey()
+                                         .AttestationChallenge("foo")
+                                         .AttestationApplicationId("bar")
+                                         .Authorization(TAG_CERTIFICATE_SERIAL, serial_blob)
+                                         .Authorization(TAG_CERTIFICATE_SUBJECT, subject_der)
+                                         .Authorization(TAG_NO_AUTH_REQUIRED)
+                                         .SetDefaultValidity(),
+                                 attest_key_opt, &key_blob_list[i], &attested_key_characteristics,
+                                 &cert_chain_list[i]);
         } else {
-            EXPECT_EQ(ErrorCode::OK,
-                      GenerateKey(AuthorizationSetBuilder()
-                                          .RsaKey(2048, 65537)
-                                          .AttestKey()
-                                          .AttestationChallenge("foo")
-                                          .AttestationApplicationId("bar")
-                                          .Authorization(TAG_CERTIFICATE_SERIAL, serial_blob)
-                                          .Authorization(TAG_CERTIFICATE_SUBJECT, subject_der)
-                                          .Authorization(TAG_NO_AUTH_REQUIRED)
-                                          .SetDefaultValidity(),
-                                  attest_key_opt, &key_blob_list[i], &attested_key_characteristics,
-                                  &cert_chain_list[i]));
+            result = GenerateKey(AuthorizationSetBuilder()
+                                         .RsaKey(2048, 65537)
+                                         .AttestKey()
+                                         .AttestationChallenge("foo")
+                                         .AttestationApplicationId("bar")
+                                         .Authorization(TAG_CERTIFICATE_SERIAL, serial_blob)
+                                         .Authorization(TAG_CERTIFICATE_SUBJECT, subject_der)
+                                         .Authorization(TAG_NO_AUTH_REQUIRED)
+                                         .SetDefaultValidity(),
+                                 attest_key_opt, &key_blob_list[i], &attested_key_characteristics,
+                                 &cert_chain_list[i]);
         }
+        // Strongbox may not support factory provisioned attestation key.
+        if (SecLevel() == SecurityLevel::STRONGBOX) {
+            if (result == ErrorCode::ATTESTATION_KEYS_NOT_PROVISIONED) return;
+        }
+        ASSERT_EQ(ErrorCode::OK, result);
 
         AuthorizationSet hw_enforced = HwEnforcedAuthorizations(attested_key_characteristics);
         AuthorizationSet sw_enforced = SwEnforcedAuthorizations(attested_key_characteristics);
diff --git a/security/keymint/aidl/vts/functional/KeyMintAidlTestBase.cpp b/security/keymint/aidl/vts/functional/KeyMintAidlTestBase.cpp
index 146a527..ff4036c 100644
--- a/security/keymint/aidl/vts/functional/KeyMintAidlTestBase.cpp
+++ b/security/keymint/aidl/vts/functional/KeyMintAidlTestBase.cpp
@@ -1228,6 +1228,14 @@
     }
 }
 
+vector<uint64_t> KeyMintAidlTestBase::ValidExponents() {
+    if (SecLevel() == SecurityLevel::STRONGBOX) {
+        return {65537};
+    } else {
+        return {3, 65537};
+    }
+}
+
 vector<Digest> KeyMintAidlTestBase::ValidDigests(bool withNone, bool withMD5) {
     switch (SecLevel()) {
         case SecurityLevel::SOFTWARE:
diff --git a/security/keymint/aidl/vts/functional/KeyMintAidlTestBase.h b/security/keymint/aidl/vts/functional/KeyMintAidlTestBase.h
index 27cb99c..6fb5bf5 100644
--- a/security/keymint/aidl/vts/functional/KeyMintAidlTestBase.h
+++ b/security/keymint/aidl/vts/functional/KeyMintAidlTestBase.h
@@ -253,7 +253,10 @@
                                                      .SetDefaultValidity();
         tagModifier(&rsaBuilder);
         errorCode = GenerateKey(rsaBuilder, &rsaKeyData.blob, &rsaKeyData.characteristics);
-        EXPECT_EQ(expectedReturn, errorCode);
+        if (!(SecLevel() == SecurityLevel::STRONGBOX &&
+              ErrorCode::ATTESTATION_KEYS_NOT_PROVISIONED == errorCode)) {
+            EXPECT_EQ(expectedReturn, errorCode);
+        }
 
         /* ECDSA */
         KeyData ecdsaKeyData;
@@ -265,7 +268,10 @@
                                                        .SetDefaultValidity();
         tagModifier(&ecdsaBuilder);
         errorCode = GenerateKey(ecdsaBuilder, &ecdsaKeyData.blob, &ecdsaKeyData.characteristics);
-        EXPECT_EQ(expectedReturn, errorCode);
+        if (!(SecLevel() == SecurityLevel::STRONGBOX &&
+              ErrorCode::ATTESTATION_KEYS_NOT_PROVISIONED == errorCode)) {
+            EXPECT_EQ(expectedReturn, errorCode);
+        }
         return {aesKeyData, hmacKeyData, rsaKeyData, ecdsaKeyData};
     }
     bool IsSecure() const { return securityLevel_ != SecurityLevel::SOFTWARE; }
@@ -282,6 +288,7 @@
     vector<EcCurve> InvalidCurves();
 
     vector<Digest> ValidDigests(bool withNone, bool withMD5);
+    vector<uint64_t> ValidExponents();
 
     static vector<string> build_params() {
         auto params = ::android::getAidlHalInstanceNames(IKeyMintDevice::descriptor);
diff --git a/security/keymint/aidl/vts/functional/KeyMintTest.cpp b/security/keymint/aidl/vts/functional/KeyMintTest.cpp
index 7357ac7..6263c0a 100644
--- a/security/keymint/aidl/vts/functional/KeyMintTest.cpp
+++ b/security/keymint/aidl/vts/functional/KeyMintTest.cpp
@@ -1036,18 +1036,21 @@
     for (auto key_size : ValidKeySizes(Algorithm::RSA)) {
         vector<uint8_t> key_blob;
         vector<KeyCharacteristics> key_characteristics;
-        ASSERT_EQ(ErrorCode::OK,
-                  GenerateKey(AuthorizationSetBuilder()
-                                      .RsaSigningKey(key_size, 65537)
-                                      .Digest(Digest::NONE)
-                                      .Padding(PaddingMode::NONE)
-                                      .AttestationChallenge(challenge)
-                                      .AttestationApplicationId(app_id)
-                                      .Authorization(TAG_NO_AUTH_REQUIRED)
-                                      .Authorization(TAG_CERTIFICATE_SERIAL, serial_blob)
-                                      .Authorization(TAG_CERTIFICATE_SUBJECT, subject_der)
-                                      .SetDefaultValidity(),
-                              &key_blob, &key_characteristics));
+        auto result = GenerateKey(AuthorizationSetBuilder()
+                                          .RsaSigningKey(key_size, 65537)
+                                          .Digest(Digest::NONE)
+                                          .Padding(PaddingMode::NONE)
+                                          .AttestationChallenge(challenge)
+                                          .AttestationApplicationId(app_id)
+                                          .Authorization(TAG_NO_AUTH_REQUIRED)
+                                          .Authorization(TAG_CERTIFICATE_SERIAL, serial_blob)
+                                          .Authorization(TAG_CERTIFICATE_SUBJECT, subject_der)
+                                          .SetDefaultValidity(),
+                                  &key_blob, &key_characteristics);
+        // Strongbox may not support factory provisioned attestation key.
+        if (SecLevel() == SecurityLevel::STRONGBOX) {
+            if (result == ErrorCode::ATTESTATION_KEYS_NOT_PROVISIONED) return;
+        }
 
         ASSERT_GT(key_blob.size(), 0U);
         CheckBaseParams(key_characteristics);
@@ -1169,17 +1172,21 @@
 
     vector<uint8_t> key_blob;
     vector<KeyCharacteristics> key_characteristics;
-    ASSERT_EQ(ErrorCode::OK,
-              GenerateKey(AuthorizationSetBuilder()
-                                  .RsaEncryptionKey(key_size, 65537)
-                                  .Padding(PaddingMode::NONE)
-                                  .AttestationChallenge(challenge)
-                                  .AttestationApplicationId(app_id)
-                                  .Authorization(TAG_NO_AUTH_REQUIRED)
-                                  .Authorization(TAG_CERTIFICATE_SERIAL, serial_blob)
-                                  .Authorization(TAG_CERTIFICATE_SUBJECT, subject_der)
-                                  .SetDefaultValidity(),
-                          &key_blob, &key_characteristics));
+    auto result = GenerateKey(AuthorizationSetBuilder()
+                                      .RsaEncryptionKey(key_size, 65537)
+                                      .Padding(PaddingMode::NONE)
+                                      .AttestationChallenge(challenge)
+                                      .AttestationApplicationId(app_id)
+                                      .Authorization(TAG_NO_AUTH_REQUIRED)
+                                      .Authorization(TAG_CERTIFICATE_SERIAL, serial_blob)
+                                      .Authorization(TAG_CERTIFICATE_SUBJECT, subject_der)
+                                      .SetDefaultValidity(),
+                              &key_blob, &key_characteristics);
+    // Strongbox may not support factory provisioned attestation key.
+    if (SecLevel() == SecurityLevel::STRONGBOX) {
+        if (result == ErrorCode::ATTESTATION_KEYS_NOT_PROVISIONED) return;
+    }
+    ASSERT_EQ(ErrorCode::OK, result);
 
     ASSERT_GT(key_blob.size(), 0U);
     AuthorizationSet auths;
@@ -1281,15 +1288,19 @@
     vector<uint8_t> key_blob;
     vector<KeyCharacteristics> key_characteristics;
 
-    ASSERT_EQ(ErrorCode::ATTESTATION_APPLICATION_ID_MISSING,
-              GenerateKey(AuthorizationSetBuilder()
-                                  .RsaSigningKey(2048, 65537)
-                                  .Digest(Digest::NONE)
-                                  .Padding(PaddingMode::NONE)
-                                  .AttestationChallenge(challenge)
-                                  .Authorization(TAG_NO_AUTH_REQUIRED)
-                                  .SetDefaultValidity(),
-                          &key_blob, &key_characteristics));
+    auto result = GenerateKey(AuthorizationSetBuilder()
+                                      .RsaSigningKey(2048, 65537)
+                                      .Digest(Digest::NONE)
+                                      .Padding(PaddingMode::NONE)
+                                      .AttestationChallenge(challenge)
+                                      .Authorization(TAG_NO_AUTH_REQUIRED)
+                                      .SetDefaultValidity(),
+                              &key_blob, &key_characteristics);
+    // Strongbox may not support factory provisioned attestation key.
+    if (SecLevel() == SecurityLevel::STRONGBOX) {
+        if (result == ErrorCode::ATTESTATION_KEYS_NOT_PROVISIONED) return;
+    }
+    ASSERT_EQ(ErrorCode::ATTESTATION_APPLICATION_ID_MISSING, result);
 }
 
 /*
@@ -1399,19 +1410,23 @@
     for (auto key_size : ValidKeySizes(Algorithm::RSA)) {
         vector<uint8_t> key_blob;
         vector<KeyCharacteristics> key_characteristics;
-        ASSERT_EQ(ErrorCode::OK,
-                  GenerateKey(AuthorizationSetBuilder()
-                                      .RsaSigningKey(key_size, 65537)
-                                      .Digest(Digest::NONE)
-                                      .Padding(PaddingMode::NONE)
-                                      .AttestationChallenge(challenge)
-                                      .AttestationApplicationId(app_id)
-                                      .Authorization(TAG_NO_AUTH_REQUIRED)
-                                      .Authorization(TAG_USAGE_COUNT_LIMIT, 1)
-                                      .Authorization(TAG_CERTIFICATE_SERIAL, serial_blob)
-                                      .Authorization(TAG_CERTIFICATE_SUBJECT, subject_der)
-                                      .SetDefaultValidity(),
-                              &key_blob, &key_characteristics));
+        auto result = GenerateKey(AuthorizationSetBuilder()
+                                          .RsaSigningKey(key_size, 65537)
+                                          .Digest(Digest::NONE)
+                                          .Padding(PaddingMode::NONE)
+                                          .AttestationChallenge(challenge)
+                                          .AttestationApplicationId(app_id)
+                                          .Authorization(TAG_NO_AUTH_REQUIRED)
+                                          .Authorization(TAG_USAGE_COUNT_LIMIT, 1)
+                                          .Authorization(TAG_CERTIFICATE_SERIAL, serial_blob)
+                                          .Authorization(TAG_CERTIFICATE_SUBJECT, subject_der)
+                                          .SetDefaultValidity(),
+                                  &key_blob, &key_characteristics);
+        // Strongbox may not support factory provisioned attestation key.
+        if (SecLevel() == SecurityLevel::STRONGBOX) {
+            if (result == ErrorCode::ATTESTATION_KEYS_NOT_PROVISIONED) return;
+        }
+        ASSERT_EQ(ErrorCode::OK, result);
 
         ASSERT_GT(key_blob.size(), 0U);
         CheckBaseParams(key_characteristics);
@@ -1601,17 +1616,21 @@
     for (auto curve : ValidCurves()) {
         vector<uint8_t> key_blob;
         vector<KeyCharacteristics> key_characteristics;
-        ASSERT_EQ(ErrorCode::OK,
-                  GenerateKey(AuthorizationSetBuilder()
-                                      .Authorization(TAG_NO_AUTH_REQUIRED)
-                                      .EcdsaSigningKey(curve)
-                                      .Digest(Digest::NONE)
-                                      .AttestationChallenge(challenge)
-                                      .AttestationApplicationId(app_id)
-                                      .Authorization(TAG_CERTIFICATE_SERIAL, serial_blob)
-                                      .Authorization(TAG_CERTIFICATE_SUBJECT, subject_der)
-                                      .SetDefaultValidity(),
-                              &key_blob, &key_characteristics));
+        auto result = GenerateKey(AuthorizationSetBuilder()
+                                          .Authorization(TAG_NO_AUTH_REQUIRED)
+                                          .EcdsaSigningKey(curve)
+                                          .Digest(Digest::NONE)
+                                          .AttestationChallenge(challenge)
+                                          .AttestationApplicationId(app_id)
+                                          .Authorization(TAG_CERTIFICATE_SERIAL, serial_blob)
+                                          .Authorization(TAG_CERTIFICATE_SUBJECT, subject_der)
+                                          .SetDefaultValidity(),
+                                  &key_blob, &key_characteristics);
+        // Strongbox may not support factory provisioned attestation key.
+        if (SecLevel() == SecurityLevel::STRONGBOX) {
+            if (result == ErrorCode::ATTESTATION_KEYS_NOT_PROVISIONED) return;
+        }
+        ASSERT_EQ(ErrorCode::OK, result);
         ASSERT_GT(key_blob.size(), 0U);
         CheckBaseParams(key_characteristics);
         CheckCharacteristics(key_blob, key_characteristics);
@@ -1745,6 +1764,10 @@
             // Tag not required to be supported by all KeyMint implementations.
             continue;
         }
+        // Strongbox may not support factory provisioned attestation key.
+        if (SecLevel() == SecurityLevel::STRONGBOX) {
+            if (result == ErrorCode::ATTESTATION_KEYS_NOT_PROVISIONED) return;
+        }
         ASSERT_EQ(result, ErrorCode::OK);
         ASSERT_GT(key_blob.size(), 0U);
 
@@ -1840,6 +1863,10 @@
         AuthorizationSetBuilder builder = base_builder;
         builder.push_back(tag);
         auto result = GenerateKey(builder, &key_blob, &key_characteristics);
+        // Strongbox may not support factory provisioned attestation key.
+        if (SecLevel() == SecurityLevel::STRONGBOX) {
+            if (result == ErrorCode::ATTESTATION_KEYS_NOT_PROVISIONED) return;
+        }
         if (result == ErrorCode::CANNOT_ATTEST_IDS) {
             // Device ID attestation is optional; KeyMint may not support it at all.
             continue;
@@ -1997,6 +2024,10 @@
                                       .Authorization(TAG_CERTIFICATE_SUBJECT, subject_der)
                                       .SetDefaultValidity(),
                               &key_blob, &key_characteristics);
+    // Strongbox may not support factory provisioned attestation key.
+    if (SecLevel() == SecurityLevel::STRONGBOX) {
+        if (result == ErrorCode::ATTESTATION_KEYS_NOT_PROVISIONED) return;
+    }
     ASSERT_EQ(result, ErrorCode::OK);
     ASSERT_GT(key_blob.size(), 0U);
 
@@ -2076,13 +2107,17 @@
     vector<uint8_t> key_blob;
     vector<KeyCharacteristics> key_characteristics;
 
-    ASSERT_EQ(ErrorCode::ATTESTATION_APPLICATION_ID_MISSING,
-              GenerateKey(AuthorizationSetBuilder()
-                                  .EcdsaSigningKey(EcCurve::P_256)
-                                  .Digest(Digest::NONE)
-                                  .AttestationChallenge(challenge)
-                                  .SetDefaultValidity(),
-                          &key_blob, &key_characteristics));
+    auto result = GenerateKey(AuthorizationSetBuilder()
+                                      .EcdsaSigningKey(EcCurve::P_256)
+                                      .Digest(Digest::NONE)
+                                      .AttestationChallenge(challenge)
+                                      .SetDefaultValidity(),
+                              &key_blob, &key_characteristics);
+    // Strongbox may not support factory provisioned attestation key.
+    if (SecLevel() == SecurityLevel::STRONGBOX) {
+        if (result == ErrorCode::ATTESTATION_KEYS_NOT_PROVISIONED) return;
+    }
+    ASSERT_EQ(ErrorCode::ATTESTATION_APPLICATION_ID_MISSING, result);
 }
 
 /*
@@ -2139,14 +2174,19 @@
         const string app_id(length, 'a');
         vector<uint8_t> key_blob;
         vector<KeyCharacteristics> key_characteristics;
-        ASSERT_EQ(ErrorCode::OK, GenerateKey(AuthorizationSetBuilder()
-                                                     .Authorization(TAG_NO_AUTH_REQUIRED)
-                                                     .EcdsaSigningKey(EcCurve::P_256)
-                                                     .Digest(Digest::NONE)
-                                                     .AttestationChallenge(challenge)
-                                                     .AttestationApplicationId(app_id)
-                                                     .SetDefaultValidity(),
-                                             &key_blob, &key_characteristics));
+        auto result = GenerateKey(AuthorizationSetBuilder()
+                                          .Authorization(TAG_NO_AUTH_REQUIRED)
+                                          .EcdsaSigningKey(EcCurve::P_256)
+                                          .Digest(Digest::NONE)
+                                          .AttestationChallenge(challenge)
+                                          .AttestationApplicationId(app_id)
+                                          .SetDefaultValidity(),
+                                  &key_blob, &key_characteristics);
+        // Strongbox may not support factory provisioned attestation key.
+        if (SecLevel() == SecurityLevel::STRONGBOX) {
+            if (result == ErrorCode::ATTESTATION_KEYS_NOT_PROVISIONED) return;
+        }
+        ASSERT_EQ(ErrorCode::OK, result);
         ASSERT_GT(key_blob.size(), 0U);
         CheckBaseParams(key_characteristics);
         CheckCharacteristics(key_blob, key_characteristics);
@@ -4646,7 +4686,7 @@
  * Verifies that raw RSA decryption works.
  */
 TEST_P(EncryptionOperationsTest, RsaNoPaddingSuccess) {
-    for (uint64_t exponent : {3, 65537}) {
+    for (uint64_t exponent : ValidExponents()) {
         ASSERT_EQ(ErrorCode::OK, GenerateKey(AuthorizationSetBuilder()
                                                      .Authorization(TAG_NO_AUTH_REQUIRED)
                                                      .RsaEncryptionKey(2048, exponent)
@@ -7654,14 +7694,23 @@
             });
 
     for (const auto& keyData : {aesKeyData, hmacKeyData, rsaKeyData, ecdsaKeyData}) {
+        // Strongbox may not support factory attestation. Key creation might fail with
+        // ErrorCode::ATTESTATION_KEYS_NOT_PROVISIONED
+        if (SecLevel() == SecurityLevel::STRONGBOX && keyData.blob.size() == 0U) {
+            continue;
+        }
         ASSERT_GT(keyData.blob.size(), 0U);
         AuthorizationSet crypto_params = SecLevelAuthorizations(keyData.characteristics);
         EXPECT_TRUE(crypto_params.Contains(TAG_EARLY_BOOT_ONLY)) << crypto_params;
     }
     CheckedDeleteKey(&aesKeyData.blob);
     CheckedDeleteKey(&hmacKeyData.blob);
-    CheckedDeleteKey(&rsaKeyData.blob);
-    CheckedDeleteKey(&ecdsaKeyData.blob);
+    if (rsaKeyData.blob.size() != 0U) {
+        CheckedDeleteKey(&rsaKeyData.blob);
+    }
+    if (ecdsaKeyData.blob.size() != 0U) {
+        CheckedDeleteKey(&ecdsaKeyData.blob);
+    }
 }
 
 /*
diff --git a/wifi/supplicant/aidl/aidl_api/android.hardware.wifi.supplicant/current/android/hardware/wifi/supplicant/ISupplicantCallback.aidl b/wifi/supplicant/aidl/aidl_api/android.hardware.wifi.supplicant/current/android/hardware/wifi/supplicant/ISupplicantCallback.aidl
index 72ab3b9..7281053 100644
--- a/wifi/supplicant/aidl/aidl_api/android.hardware.wifi.supplicant/current/android/hardware/wifi/supplicant/ISupplicantCallback.aidl
+++ b/wifi/supplicant/aidl/aidl_api/android.hardware.wifi.supplicant/current/android/hardware/wifi/supplicant/ISupplicantCallback.aidl
@@ -36,5 +36,4 @@
 interface ISupplicantCallback {
   oneway void onInterfaceCreated(in String ifaceName);
   oneway void onInterfaceRemoved(in String ifaceName);
-  oneway void onTerminating();
 }
diff --git a/wifi/supplicant/aidl/android/hardware/wifi/supplicant/ISupplicantCallback.aidl b/wifi/supplicant/aidl/android/hardware/wifi/supplicant/ISupplicantCallback.aidl
index 6f15900..8e59ec9 100644
--- a/wifi/supplicant/aidl/android/hardware/wifi/supplicant/ISupplicantCallback.aidl
+++ b/wifi/supplicant/aidl/android/hardware/wifi/supplicant/ISupplicantCallback.aidl
@@ -24,23 +24,18 @@
  * |ISupplicant.registerCallback| method.
  */
 @VintfStability
-interface ISupplicantCallback {
+oneway interface ISupplicantCallback {
     /**
      * Used to indicate that a new interface has been created.
      *
      * @param ifaceName Name of the network interface, e.g., wlan0
      */
-    oneway void onInterfaceCreated(in String ifaceName);
+    void onInterfaceCreated(in String ifaceName);
 
     /**
      * Used to indicate that an interface has been removed.
      *
      * @param ifaceName Name of the network interface, e.g., wlan0
      */
-    oneway void onInterfaceRemoved(in String ifaceName);
-
-    /**
-     * Used to indicate that the supplicant daemon is terminating.
-     */
-    oneway void onTerminating();
+    void onInterfaceRemoved(in String ifaceName);
 }
diff --git a/wifi/supplicant/aidl/android/hardware/wifi/supplicant/ISupplicantP2pIfaceCallback.aidl b/wifi/supplicant/aidl/android/hardware/wifi/supplicant/ISupplicantP2pIfaceCallback.aidl
index da17c7b..7c8c1f2 100644
--- a/wifi/supplicant/aidl/android/hardware/wifi/supplicant/ISupplicantP2pIfaceCallback.aidl
+++ b/wifi/supplicant/aidl/android/hardware/wifi/supplicant/ISupplicantP2pIfaceCallback.aidl
@@ -31,7 +31,7 @@
  * corresponding |ISupplicantP2pIface.registerCallback| method.
  */
 @VintfStability
-interface ISupplicantP2pIfaceCallback {
+oneway interface ISupplicantP2pIfaceCallback {
     /**
      * Used to indicate that a P2P device has been found.
      *
@@ -50,7 +50,7 @@
      * @param wfdDeviceInfo WFD device info as described in section 5.1.2 of WFD
      *        technical specification v1.0.0.
      */
-    oneway void onDeviceFound(in byte[] srcAddress, in byte[] p2pDeviceAddress,
+    void onDeviceFound(in byte[] srcAddress, in byte[] p2pDeviceAddress,
             in byte[] primaryDeviceType, in String deviceName, in WpsConfigMethods configMethods,
             in byte deviceCapabilities, in P2pGroupCapabilityMask groupCapabilities,
             in byte[] wfdDeviceInfo);
@@ -60,19 +60,19 @@
      *
      * @param p2pDeviceAddress P2P device address.
      */
-    oneway void onDeviceLost(in byte[] p2pDeviceAddress);
+    void onDeviceLost(in byte[] p2pDeviceAddress);
 
     /**
      * Used to indicate the termination of P2P find operation.
      */
-    oneway void onFindStopped();
+    void onFindStopped();
 
     /**
      * Used to indicate the completion of a P2P Group Owner negotiation request.
      *
      * @param status Status of the GO negotiation.
      */
-    oneway void onGoNegotiationCompleted(in P2pStatusCode status);
+    void onGoNegotiationCompleted(in P2pStatusCode status);
 
     /**
      * Used to indicate the reception of a P2P Group Owner negotiation request.
@@ -81,19 +81,19 @@
      *        negotiation request.
      * @param passwordId Type of password.
      */
-    oneway void onGoNegotiationRequest(in byte[] srcAddress, in WpsDevPasswordId passwordId);
+    void onGoNegotiationRequest(in byte[] srcAddress, in WpsDevPasswordId passwordId);
 
     /**
      * Used to indicate a failure to form a P2P group.
      *
      * @param failureReason Failure reason string for debug purposes.
      */
-    oneway void onGroupFormationFailure(in String failureReason);
+    void onGroupFormationFailure(in String failureReason);
 
     /**
      * Used to indicate a successful formation of a P2P group.
      */
-    oneway void onGroupFormationSuccess();
+    void onGroupFormationSuccess();
 
     /**
      * Used to indicate the removal of a P2P group.
@@ -101,7 +101,7 @@
      * @param groupIfName Interface name of the group. (For ex: p2p-p2p0-1)
      * @param isGroupOwner Whether this device is owner of the group.
      */
-    oneway void onGroupRemoved(in String groupIfname, in boolean isGroupOwner);
+    void onGroupRemoved(in String groupIfname, in boolean isGroupOwner);
 
     /**
      * Used to indicate the start of a P2P group.
@@ -115,7 +115,7 @@
      * @param goDeviceAddress MAC Address of the owner of this group.
      * @param isPersistent Whether this group is persisted or not.
      */
-    oneway void onGroupStarted(in String groupIfname, in boolean isGroupOwner, in byte[] ssid,
+    void onGroupStarted(in String groupIfname, in boolean isGroupOwner, in byte[] ssid,
             in int frequency, in byte[] psk, in String passphrase, in byte[] goDeviceAddress,
             in boolean isPersistent);
 
@@ -128,8 +128,8 @@
      * @param persistentNetworkId Persistent network Id of the group.
      * @param operatingFrequency Frequency on which the invitation was received.
      */
-    oneway void onInvitationReceived(in byte[] srcAddress, in byte[] goDeviceAddress,
-            in byte[] bssid, in int persistentNetworkId, in int operatingFrequency);
+    void onInvitationReceived(in byte[] srcAddress, in byte[] goDeviceAddress, in byte[] bssid,
+            in int persistentNetworkId, in int operatingFrequency);
 
     /**
      * Used to indicate the result of the P2P invitation request.
@@ -137,7 +137,7 @@
      * @param bssid Bssid of the group.
      * @param status Status of the invitation.
      */
-    oneway void onInvitationResult(in byte[] bssid, in P2pStatusCode status);
+    void onInvitationResult(in byte[] bssid, in P2pStatusCode status);
 
     /**
      * Used to indicate the completion of a P2P provision discovery request.
@@ -148,7 +148,7 @@
      * @param configMethods Mask of WPS configuration methods supported.
      * @param generatedPin 8 digit pin generated.
      */
-    oneway void onProvisionDiscoveryCompleted(in byte[] p2pDeviceAddress, in boolean isRequest,
+    void onProvisionDiscoveryCompleted(in byte[] p2pDeviceAddress, in boolean isRequest,
             in P2pProvDiscStatusCode status, in WpsConfigMethods configMethods,
             in String generatedPin);
 
@@ -174,7 +174,7 @@
      * @param wfdR2DeviceInfo WFD R2 device info as described in section 5.1.12 of WFD
      *        technical specification v2.1.
      */
-    oneway void onR2DeviceFound(in byte[] srcAddress, in byte[] p2pDeviceAddress,
+    void onR2DeviceFound(in byte[] srcAddress, in byte[] p2pDeviceAddress,
             in byte[] primaryDeviceType, in String deviceName, in WpsConfigMethods configMethods,
             in byte deviceCapabilities, in P2pGroupCapabilityMask groupCapabilities,
             in byte[] wfdDeviceInfo, in byte[] wfdR2DeviceInfo);
@@ -187,8 +187,7 @@
      *        Wifi P2P Technical specification v1.2.
      * @parm tlvs Refer to section 3.1.3.1 of Wifi P2P Technical specification v1.2.
      */
-    oneway void onServiceDiscoveryResponse(
-            in byte[] srcAddress, in char updateIndicator, in byte[] tlvs);
+    void onServiceDiscoveryResponse(in byte[] srcAddress, in char updateIndicator, in byte[] tlvs);
 
     /**
      * Used to indicate when a STA device is connected to this device.
@@ -196,7 +195,7 @@
      * @param srcAddress MAC address of the device that was authorized.
      * @param p2pDeviceAddress P2P device address.
      */
-    oneway void onStaAuthorized(in byte[] srcAddress, in byte[] p2pDeviceAddress);
+    void onStaAuthorized(in byte[] srcAddress, in byte[] p2pDeviceAddress);
 
     /**
      * Used to indicate when a STA device is disconnected from this device.
@@ -204,7 +203,7 @@
      * @param srcAddress MAC address of the device that was deauthorized.
      * @param p2pDeviceAddress P2P device address.
      */
-    oneway void onStaDeauthorized(in byte[] srcAddress, in byte[] p2pDeviceAddress);
+    void onStaDeauthorized(in byte[] srcAddress, in byte[] p2pDeviceAddress);
 
     /**
      * Used to indicate that operating frequency has changed for this P2P group interface.
@@ -212,7 +211,7 @@
      * @param groupIfName Interface name of the group. (For ex: p2p-p2p0-1)
      * @param frequency New operating frequency in MHz.
      */
-    oneway void onGroupFrequencyChanged(in String groupIfname, in int frequency);
+    void onGroupFrequencyChanged(in String groupIfname, in int frequency);
 
     /**
      * Used to indicate that a P2P device has been found.
@@ -240,7 +239,7 @@
      *         Information technology. The length indicates the size of the payload.
      *         Multiple information elements may be appended within the byte array.
      */
-    oneway void onDeviceFoundWithVendorElements(in byte[] srcAddress, in byte[] p2pDeviceAddress,
+    void onDeviceFoundWithVendorElements(in byte[] srcAddress, in byte[] p2pDeviceAddress,
             in byte[] primaryDeviceType, in String deviceName, in WpsConfigMethods configMethods,
             in byte deviceCapabilities, in P2pGroupCapabilityMask groupCapabilities,
             in byte[] wfdDeviceInfo, in byte[] wfdR2DeviceInfo, in byte[] vendorElemBytes);
diff --git a/wifi/supplicant/aidl/android/hardware/wifi/supplicant/ISupplicantStaIface.aidl b/wifi/supplicant/aidl/android/hardware/wifi/supplicant/ISupplicantStaIface.aidl
index 1b7f5bd..8ab0c82 100644
--- a/wifi/supplicant/aidl/android/hardware/wifi/supplicant/ISupplicantStaIface.aidl
+++ b/wifi/supplicant/aidl/android/hardware/wifi/supplicant/ISupplicantStaIface.aidl
@@ -452,12 +452,12 @@
      * This allows other radio works to be performed. If this method is not
      * invoked (e.g., due to the external program terminating), supplicant
      * must time out the radio work item on the iface and send
-     * |ISupplicantCallback.onExtRadioWorkTimeout| event to indicate
+     * |ISupplicantStaIfaceCallback.onExtRadioWorkTimeout| event to indicate
      * that this has happened.
      *
      * This method may also be used to cancel items that have been scheduled
      * via |addExtRadioWork|, but have not yet been started (notified via
-     * |ISupplicantCallback.onExtRadioWorkStart|).
+     * |ISupplicantStaIfaceCallback.onExtRadioWorkStart|).
      *
      * @param id Identifier generated for the radio work addition
      *         (using |addExtRadioWork|).
diff --git a/wifi/supplicant/aidl/android/hardware/wifi/supplicant/ISupplicantStaIfaceCallback.aidl b/wifi/supplicant/aidl/android/hardware/wifi/supplicant/ISupplicantStaIfaceCallback.aidl
index 369d0da..ade68f0 100644
--- a/wifi/supplicant/aidl/android/hardware/wifi/supplicant/ISupplicantStaIfaceCallback.aidl
+++ b/wifi/supplicant/aidl/android/hardware/wifi/supplicant/ISupplicantStaIfaceCallback.aidl
@@ -42,7 +42,7 @@
  * corresponding |ISupplicantStaIface.registerCallback| method.
  */
 @VintfStability
-interface ISupplicantStaIfaceCallback {
+oneway interface ISupplicantStaIfaceCallback {
     /**
      * Used to indicate the result of ANQP (either for IEEE 802.11u Interworking
      * or Hotspot 2.0) query.
@@ -53,7 +53,7 @@
      * @param hs20Data ANQP data fetched from the Hotspot 2.0 access point.
      *        All the fields in this struct must be empty if the query failed.
      */
-    oneway void onAnqpQueryDone(in byte[] bssid, in AnqpData data, in Hs20AnqpData hs20Data);
+    void onAnqpQueryDone(in byte[] bssid, in AnqpData data, in Hs20AnqpData hs20Data);
 
     /**
      * Used to indicate an association rejection received from the AP
@@ -61,14 +61,14 @@
      *
      * @param assocRejectData Association Rejection related information.
      */
-    oneway void onAssociationRejected(in AssociationRejectionData assocRejectData);
+    void onAssociationRejected(in AssociationRejectionData assocRejectData);
 
     /**
      * Used to indicate the timeout of authentication to an AP.
      *
      * @param bssid BSSID of the corresponding AP.
      */
-    oneway void onAuthenticationTimeout(in byte[] bssid);
+    void onAuthenticationTimeout(in byte[] bssid);
 
     /**
      * Indicates BTM request frame handling status.
@@ -76,7 +76,7 @@
      * @param tmData Data retrieved from received BSS transition management
      * request frame.
      */
-    oneway void onBssTmHandlingDone(in BssTmData tmData);
+    void onBssTmHandlingDone(in BssTmData tmData);
 
     /**
      * Used to indicate the change of active bssid.
@@ -86,7 +86,7 @@
      * @param reason Reason why the bssid changed.
      * @param bssid BSSID of the corresponding AP.
      */
-    oneway void onBssidChanged(in BssidChangeReason reason, in byte[] bssid);
+    void onBssidChanged(in BssidChangeReason reason, in byte[] bssid);
 
     /**
      * Used to indicate the disconnection from the currently connected
@@ -98,7 +98,7 @@
      * @param reasonCode 802.11 code to indicate the disconnect reason
      *        from access point. Refer to section 8.4.1.7 of IEEE802.11 spec.
      */
-    oneway void onDisconnected(
+    void onDisconnected(
             in byte[] bssid, in boolean locallyGenerated, in StaIfaceReasonCode reasonCode);
 
     /**
@@ -115,31 +115,31 @@
      * bandList: A list of band parameters that are supported by the Enrollee expressed as the
      *     Operating Class.
      */
-    oneway void onDppFailure(
+    void onDppFailure(
             in DppFailureCode code, in String ssid, in String channelList, in char[] bandList);
 
     /**
      * Indicates a DPP progress event.
      */
-    oneway void onDppProgress(in DppProgressCode code);
+    void onDppProgress(in DppProgressCode code);
 
     /**
      * Indicates a DPP success event.
      */
-    oneway void onDppSuccess(in DppEventType event);
+    void onDppSuccess(in DppEventType event);
 
     /**
      * Indicates DPP configuration received success event in Enrolee mode.
      * This is also triggered when Configurator generates credentials for itself
      * using generateSelfDppConfiguration() API
      */
-    oneway void onDppSuccessConfigReceived(in byte[] ssid, in String password, in byte[] psk,
+    void onDppSuccessConfigReceived(in byte[] ssid, in String password, in byte[] psk,
             in DppAkm securityAkm, in DppConnectionKeys dppConnectionKeys);
 
     /**
      * Indicates DPP configuration sent success event (Configurator mode).
      */
-    oneway void onDppSuccessConfigSent();
+    void onDppSuccessConfigSent();
 
     /**
      * Indicates an EAP authentication failure.
@@ -147,21 +147,21 @@
      *        Either standard error code (enum EapErrorCode) or
      *        private error code defined by network provider.
      */
-    oneway void onEapFailure(in int errorCode);
+    void onEapFailure(in int errorCode);
 
     /**
      * Used to indicate that the external radio work can start now.
      *
      * @param id Identifier generated for the radio work request.
      */
-    oneway void onExtRadioWorkStart(in int id);
+    void onExtRadioWorkStart(in int id);
 
     /**
      * Used to indicate that the external radio work request has timed out.
      *
      * @param id Identifier generated for the radio work request.
      */
-    oneway void onExtRadioWorkTimeout(in int id);
+    void onExtRadioWorkTimeout(in int id);
 
     /**
      * Used to indicate a Hotspot 2.0 imminent deauth notice.
@@ -172,7 +172,7 @@
      * @param reAuthDelayInSec Delay before reauthenticating.
      * @param url URL of the server.
      */
-    oneway void onHs20DeauthImminentNotice(
+    void onHs20DeauthImminentNotice(
             in byte[] bssid, in int reasonCode, in int reAuthDelayInSec, in String url);
 
     /**
@@ -183,7 +183,7 @@
      * @param data Icon data fetched from the access point.
      *        Must be empty if the query failed.
      */
-    oneway void onHs20IconQueryDone(in byte[] bssid, in String fileName, in byte[] data);
+    void onHs20IconQueryDone(in byte[] bssid, in String fileName, in byte[] data);
 
     /**
      * Used to indicate a Hotspot 2.0 subscription remediation event.
@@ -192,8 +192,7 @@
      * @param osuMethod OSU method.
      * @param url URL of the server.
      */
-    oneway void onHs20SubscriptionRemediation(
-            in byte[] bssid, in OsuMethod osuMethod, in String url);
+    void onHs20SubscriptionRemediation(in byte[] bssid, in OsuMethod osuMethod, in String url);
 
     /**
      * Used to indicate a Hotspot 2.0 terms and conditions acceptance is requested from the user
@@ -202,15 +201,14 @@
      * @param bssid BSSID of the access point.
      * @param url URL of the T&C server.
      */
-    oneway void onHs20TermsAndConditionsAcceptanceRequestedNotification(
-            in byte[] bssid, in String url);
+    void onHs20TermsAndConditionsAcceptanceRequestedNotification(in byte[] bssid, in String url);
 
     /**
      * Used to indicate that a new network has been added.
      *
      * @param id Network ID allocated to the corresponding network.
      */
-    oneway void onNetworkAdded(in int id);
+    void onNetworkAdded(in int id);
 
     /**
      * Used to indicate that the supplicant failed to find a network in scan result
@@ -219,14 +217,14 @@
      *
      * @param ssid network name supplicant tried to connect.
      */
-    oneway void onNetworkNotFound(in byte[] ssid);
+    void onNetworkNotFound(in byte[] ssid);
 
     /**
      * Used to indicate that a network has been removed.
      *
      * @param id Network ID allocated to the corresponding network.
      */
-    oneway void onNetworkRemoved(in int id);
+    void onNetworkRemoved(in int id);
 
     /**
      * Indicates pairwise master key (PMK) cache added event.
@@ -235,7 +233,7 @@
      * @param serializedEntry is serialized PMK cache entry, the content is
      *              opaque for the framework and depends on the native implementation.
      */
-    oneway void onPmkCacheAdded(in long expirationTimeInSec, in byte[] serializedEntry);
+    void onPmkCacheAdded(in long expirationTimeInSec, in byte[] serializedEntry);
 
     /**
      * Used to indicate a state change event on this particular iface. If this
@@ -256,7 +254,7 @@
      *        to a particular network.
      * @param filsHlpSent If FILS HLP IEs were included in this association.
      */
-    oneway void onStateChanged(in StaIfaceCallbackState newState, in byte[] bssid, in int id,
+    void onStateChanged(in StaIfaceCallbackState newState, in byte[] bssid, in int id,
             in byte[] ssid, in boolean filsHlpSent);
 
     /**
@@ -267,29 +265,29 @@
      * @param configError Configuration error code.
      * @param errorInd Error indication code.
      */
-    oneway void onWpsEventFail(
+    void onWpsEventFail(
             in byte[] bssid, in WpsConfigError configError, in WpsErrorIndication errorInd);
 
     /**
      * Used to indicate the overlap of a WPS PBC connection attempt.
      */
-    oneway void onWpsEventPbcOverlap();
+    void onWpsEventPbcOverlap();
 
     /**
      * Used to indicate the success of a WPS connection attempt.
      */
-    oneway void onWpsEventSuccess();
+    void onWpsEventSuccess();
 
     /**
      * Used to indicate that the AP has cleared all DSCP requests
      * associated with this device.
      */
-    oneway void onQosPolicyReset();
+    void onQosPolicyReset();
 
     /**
      * Used to indicate a DSCP request was received from the AP.
      *
      * @param qosPolicyData QoS policies info requested by the AP.
      */
-    oneway void onQosPolicyRequest(in QosPolicyData[] qosPolicyData);
+    void onQosPolicyRequest(in QosPolicyData[] qosPolicyData);
 }
diff --git a/wifi/supplicant/aidl/android/hardware/wifi/supplicant/ISupplicantStaNetworkCallback.aidl b/wifi/supplicant/aidl/android/hardware/wifi/supplicant/ISupplicantStaNetworkCallback.aidl
index 4024c35..de7b675 100644
--- a/wifi/supplicant/aidl/android/hardware/wifi/supplicant/ISupplicantStaNetworkCallback.aidl
+++ b/wifi/supplicant/aidl/android/hardware/wifi/supplicant/ISupplicantStaNetworkCallback.aidl
@@ -29,14 +29,14 @@
  * corresponding |ISupplicantStaNetwork.registerCallback| method.
  */
 @VintfStability
-interface ISupplicantStaNetworkCallback {
+oneway interface ISupplicantStaNetworkCallback {
     /**
      * Used to request EAP Identity for this particular network.
      *
      * The response for the request must be sent using the corresponding
      * |ISupplicantNetwork.sendNetworkEapIdentityResponse| call.
      */
-    oneway void onNetworkEapIdentityRequest();
+    void onNetworkEapIdentityRequest();
 
     /**
      * Used to request EAP GSM SIM authentication for this particular network.
@@ -46,7 +46,7 @@
      *
      * @param params Params associated with the request.
      */
-    oneway void onNetworkEapSimGsmAuthRequest(in NetworkRequestEapSimGsmAuthParams params);
+    void onNetworkEapSimGsmAuthRequest(in NetworkRequestEapSimGsmAuthParams params);
 
     /**
      * Used to request EAP UMTS SIM authentication for this particular network.
@@ -56,12 +56,12 @@
      *
      * @param params Params associated with the request.
      */
-    oneway void onNetworkEapSimUmtsAuthRequest(in NetworkRequestEapSimUmtsAuthParams params);
+    void onNetworkEapSimUmtsAuthRequest(in NetworkRequestEapSimUmtsAuthParams params);
 
     /**
      * Used to notify WPA3 transition disable.
      */
-    oneway void onTransitionDisable(in TransitionDisableIndication ind);
+    void onTransitionDisable(in TransitionDisableIndication ind);
 
     /**
      * Used to notify EAP certificate event.
@@ -69,6 +69,6 @@
      * On receiving a server certifidate from TLS handshake, send this certificate
      * to the framework for Trust On First Use.
      */
-    oneway void onServerCertificateAvailable(
+    void onServerCertificateAvailable(
             in int depth, in byte[] subject, in byte[] certHash, in byte[] certBlob);
 }