Merge "Adding IAudioControl#onDevicesToDuckChange"
diff --git a/audio/7.0/IStream.hal b/audio/7.0/IStream.hal
index 4fe8218..ab9aa7d 100644
--- a/audio/7.0/IStream.hal
+++ b/audio/7.0/IStream.hal
@@ -66,9 +66,10 @@
      * Retrieves basic stream configuration: sample rate, audio format,
      * channel mask.
      *
+     * @return retval operation completion status.
      * @return config basic stream configuration.
      */
-    getAudioProperties() generates (AudioConfigBase config);
+    getAudioProperties() generates (Result retval, AudioConfigBase config);
 
     /**
      * Sets stream parameters. Only sets parameters that are specified.
diff --git a/audio/7.0/config/api/current.txt b/audio/7.0/config/api/current.txt
index 1da8b09..0b2e4a4 100644
--- a/audio/7.0/config/api/current.txt
+++ b/audio/7.0/config/api/current.txt
@@ -259,6 +259,7 @@
     enum_constant public static final android.audio.policy.configuration.V7_0.AudioInOutFlag AUDIO_OUTPUT_FLAG_DIRECT;
     enum_constant public static final android.audio.policy.configuration.V7_0.AudioInOutFlag AUDIO_OUTPUT_FLAG_DIRECT_PCM;
     enum_constant public static final android.audio.policy.configuration.V7_0.AudioInOutFlag AUDIO_OUTPUT_FLAG_FAST;
+    enum_constant public static final android.audio.policy.configuration.V7_0.AudioInOutFlag AUDIO_OUTPUT_FLAG_GAPLESS_OFFLOAD;
     enum_constant public static final android.audio.policy.configuration.V7_0.AudioInOutFlag AUDIO_OUTPUT_FLAG_HW_AV_SYNC;
     enum_constant public static final android.audio.policy.configuration.V7_0.AudioInOutFlag AUDIO_OUTPUT_FLAG_IEC958_NONAUDIO;
     enum_constant public static final android.audio.policy.configuration.V7_0.AudioInOutFlag AUDIO_OUTPUT_FLAG_INCALL_MUSIC;
diff --git a/audio/7.0/config/audio_policy_configuration.xsd b/audio/7.0/config/audio_policy_configuration.xsd
index 56b3a27..a735c6d 100644
--- a/audio/7.0/config/audio_policy_configuration.xsd
+++ b/audio/7.0/config/audio_policy_configuration.xsd
@@ -181,6 +181,7 @@
             <xs:enumeration value="AUDIO_OUTPUT_FLAG_MMAP_NOIRQ" />
             <xs:enumeration value="AUDIO_OUTPUT_FLAG_VOIP_RX" />
             <xs:enumeration value="AUDIO_OUTPUT_FLAG_INCALL_MUSIC" />
+            <xs:enumeration value="AUDIO_OUTPUT_FLAG_GAPLESS_OFFLOAD" />
             <xs:enumeration value="AUDIO_INPUT_FLAG_NONE" />
             <xs:enumeration value="AUDIO_INPUT_FLAG_FAST" />
             <xs:enumeration value="AUDIO_INPUT_FLAG_HW_HOTWORD" />
diff --git a/audio/common/7.0/enums/include/android_audio_policy_configuration_V7_0-enums.h b/audio/common/7.0/enums/include/android_audio_policy_configuration_V7_0-enums.h
index 414eede..b7c1cc9 100644
--- a/audio/common/7.0/enums/include/android_audio_policy_configuration_V7_0-enums.h
+++ b/audio/common/7.0/enums/include/android_audio_policy_configuration_V7_0-enums.h
@@ -225,6 +225,10 @@
     return stringToAudioChannelMask(mask) == AudioChannelMask::UNKNOWN;
 }
 
+static inline bool isUnknownAudioContentType(const std::string& contentType) {
+    return stringToAudioContentType(contentType) == AudioContentType::UNKNOWN;
+}
+
 static inline bool isUnknownAudioDevice(const std::string& device) {
     return stringToAudioDevice(device) == AudioDevice::UNKNOWN && !isVendorExtension(device);
 }
@@ -237,6 +241,10 @@
     return stringToAudioGainMode(mode) == AudioGainMode::UNKNOWN;
 }
 
+static inline bool isUnknownAudioInOutFlag(const std::string& flag) {
+    return stringToAudioInOutFlag(flag) == AudioInOutFlag::UNKNOWN;
+}
+
 static inline bool isUnknownAudioSource(const std::string& source) {
     return stringToAudioSource(source) == AudioSource::UNKNOWN;
 }
diff --git a/audio/common/7.0/example/Effect.cpp b/audio/common/7.0/example/Effect.cpp
index 9d5ab31..27f28c6 100644
--- a/audio/common/7.0/example/Effect.cpp
+++ b/audio/common/7.0/example/Effect.cpp
@@ -107,14 +107,14 @@
 }
 
 Return<void> Effect::getConfig(getConfig_cb _hidl_cb) {
-    const EffectConfig config = {{} /* inputCfg */,
-                                 // outputCfg
-                                 {{} /* buffer */,
-                                  48000 /* samplingRateHz */,
-                                  toString(xsd::AudioChannelMask::AUDIO_CHANNEL_OUT_STEREO),
-                                  toString(xsd::AudioFormat::AUDIO_FORMAT_PCM_16_BIT),
-                                  EffectBufferAccess::ACCESS_ACCUMULATE,
-                                  0 /* mask */}};
+    const EffectConfig config = {
+            {} /* inputCfg */,
+            // outputCfg
+            {{} /* buffer */,
+             {toString(xsd::AudioFormat::AUDIO_FORMAT_PCM_16_BIT), 48000 /* samplingRateHz */,
+              toString(xsd::AudioChannelMask::AUDIO_CHANNEL_OUT_STEREO)}, /* base */
+             EffectBufferAccess::ACCESS_ACCUMULATE,
+             0 /* mask */}};
     _hidl_cb(Result::OK, config);
     return Void();
 }
diff --git a/audio/common/all-versions/default/7.0/HidlUtils.cpp b/audio/common/all-versions/default/7.0/HidlUtils.cpp
index 1a66282..c985a70 100644
--- a/audio/common/all-versions/default/7.0/HidlUtils.cpp
+++ b/audio/common/all-versions/default/7.0/HidlUtils.cpp
@@ -95,6 +95,25 @@
     return NO_ERROR;
 }
 
+status_t HidlUtils::audioChannelMasksFromHal(const std::vector<std::string>& halChannelMasks,
+                                             hidl_vec<AudioChannelMask>* channelMasks) {
+    hidl_vec<AudioChannelMask> tempChannelMasks;
+    tempChannelMasks.resize(halChannelMasks.size());
+    size_t tempPos = 0;
+    for (const auto& halChannelMask : halChannelMasks) {
+        if (!halChannelMask.empty() && !xsd::isUnknownAudioChannelMask(halChannelMask)) {
+            tempChannelMasks[tempPos++] = halChannelMask;
+        }
+    }
+    if (tempPos == tempChannelMasks.size()) {
+        *channelMasks = std::move(tempChannelMasks);
+    } else {
+        *channelMasks = hidl_vec<AudioChannelMask>(tempChannelMasks.begin(),
+                                                   tempChannelMasks.begin() + tempPos);
+    }
+    return halChannelMasks.size() == channelMasks->size() ? NO_ERROR : BAD_VALUE;
+}
+
 status_t HidlUtils::audioChannelMaskToHal(const AudioChannelMask& channelMask,
                                           audio_channel_mask_t* halChannelMask) {
     if (!xsd::isUnknownAudioChannelMask(channelMask) &&
@@ -127,6 +146,28 @@
     return result;
 }
 
+status_t HidlUtils::audioContentTypeFromHal(const audio_content_type_t halContentType,
+                                            AudioContentType* contentType) {
+    *contentType = audio_content_type_to_string(halContentType);
+    if (!contentType->empty() && !xsd::isUnknownAudioContentType(*contentType)) {
+        return NO_ERROR;
+    }
+    ALOGE("Unknown audio content type value 0x%X", halContentType);
+    *contentType = toString(xsd::AudioContentType::AUDIO_CONTENT_TYPE_UNKNOWN);
+    return BAD_VALUE;
+}
+
+status_t HidlUtils::audioContentTypeToHal(const AudioContentType& contentType,
+                                          audio_content_type_t* halContentType) {
+    if (!xsd::isUnknownAudioContentType(contentType) &&
+        audio_content_type_from_string(contentType.c_str(), halContentType)) {
+        return NO_ERROR;
+    }
+    ALOGE("Unknown audio content type \"%s\"", contentType.c_str());
+    *halContentType = AUDIO_CONTENT_TYPE_UNKNOWN;
+    return BAD_VALUE;
+}
+
 status_t HidlUtils::audioDeviceTypeFromHal(audio_devices_t halDevice, AudioDevice* device) {
     *device = audio_device_to_string(halDevice);
     if (!device->empty() && !xsd::isUnknownAudioDevice(*device)) {
@@ -155,6 +196,24 @@
     return BAD_VALUE;
 }
 
+status_t HidlUtils::audioFormatsFromHal(const std::vector<std::string>& halFormats,
+                                        hidl_vec<AudioFormat>* formats) {
+    hidl_vec<AudioFormat> tempFormats;
+    tempFormats.resize(halFormats.size());
+    size_t tempPos = 0;
+    for (const auto& halFormat : halFormats) {
+        if (!halFormat.empty() && !xsd::isUnknownAudioFormat(halFormat)) {
+            tempFormats[tempPos++] = halFormat;
+        }
+    }
+    if (tempPos == tempFormats.size()) {
+        *formats = std::move(tempFormats);
+    } else {
+        *formats = hidl_vec<AudioFormat>(tempFormats.begin(), tempFormats.begin() + tempPos);
+    }
+    return halFormats.size() == formats->size() ? NO_ERROR : BAD_VALUE;
+}
+
 status_t HidlUtils::audioFormatToHal(const AudioFormat& format, audio_format_t* halFormat) {
     if (!xsd::isUnknownAudioFormat(format) && audio_format_from_string(format.c_str(), halFormat)) {
         return NO_ERROR;
diff --git a/audio/common/all-versions/default/Android.bp b/audio/common/all-versions/default/Android.bp
index b83a58a..45f0b8f 100644
--- a/audio/common/all-versions/default/Android.bp
+++ b/audio/common/all-versions/default/Android.bp
@@ -43,6 +43,7 @@
     name: "android.hardware.audio.common-util@2-6",
     srcs: [
         "HidlUtils.cpp",
+        "HidlUtilsCommon.cpp",
         "UuidUtils.cpp",
     ],
 }
@@ -132,6 +133,7 @@
     defaults: ["android.hardware.audio.common-util_default"],
     srcs: [
         "7.0/HidlUtils.cpp",
+        "HidlUtilsCommon.cpp",
         "UuidUtils.cpp",
     ],
     shared_libs: [
diff --git a/audio/common/all-versions/default/HidlUtils.cpp b/audio/common/all-versions/default/HidlUtils.cpp
index ab3c1c7..c0dcd80 100644
--- a/audio/common/all-versions/default/HidlUtils.cpp
+++ b/audio/common/all-versions/default/HidlUtils.cpp
@@ -28,7 +28,7 @@
 namespace CPP_VERSION {
 namespace implementation {
 
-status_t HidlUtils::audioConfigFromHal(const audio_config_t& halConfig, AudioConfig* config) {
+status_t HidlUtils::audioConfigFromHal(const audio_config_t& halConfig, bool, AudioConfig* config) {
     config->sampleRateHz = halConfig.sample_rate;
     config->channelMask = EnumBitfield<AudioChannelMask>(halConfig.channel_mask);
     config->format = AudioFormat(halConfig.format);
@@ -47,8 +47,8 @@
     return NO_ERROR;
 }
 
-void HidlUtils::audioGainConfigFromHal(const struct audio_gain_config& halConfig,
-                                       AudioGainConfig* config) {
+status_t HidlUtils::audioGainConfigFromHal(const struct audio_gain_config& halConfig, bool,
+                                           AudioGainConfig* config) {
     config->index = halConfig.index;
     config->mode = EnumBitfield<AudioGainMode>(halConfig.mode);
     config->channelMask = EnumBitfield<AudioChannelMask>(halConfig.channel_mask);
@@ -56,6 +56,7 @@
         config->values[i] = halConfig.values[i];
     }
     config->rampDurationMs = halConfig.ramp_duration_ms;
+    return NO_ERROR;
 }
 
 status_t HidlUtils::audioGainConfigToHal(const AudioGainConfig& config,
@@ -71,7 +72,7 @@
     return NO_ERROR;
 }
 
-void HidlUtils::audioGainFromHal(const struct audio_gain& halGain, AudioGain* gain) {
+status_t HidlUtils::audioGainFromHal(const struct audio_gain& halGain, bool, AudioGain* gain) {
     gain->mode = EnumBitfield<AudioGainMode>(halGain.mode);
     gain->channelMask = EnumBitfield<AudioChannelMask>(halGain.channel_mask);
     gain->minValue = halGain.min_value;
@@ -80,6 +81,7 @@
     gain->stepValue = halGain.step_value;
     gain->minRampMs = halGain.min_ramp_ms;
     gain->maxRampMs = halGain.max_ramp_ms;
+    return NO_ERROR;
 }
 
 status_t HidlUtils::audioGainToHal(const AudioGain& gain, struct audio_gain* halGain) {
@@ -182,7 +184,7 @@
     config->sampleRateHz = halConfig.sample_rate;
     config->channelMask = EnumBitfield<AudioChannelMask>(halConfig.channel_mask);
     config->format = AudioFormat(halConfig.format);
-    audioGainConfigFromHal(halConfig.gain, &config->gain);
+    audioGainConfigFromHal(halConfig.gain, false /*isInput--ignored*/, &config->gain);
     switch (halConfig.type) {
         case AUDIO_PORT_TYPE_NONE:
             break;
@@ -272,7 +274,7 @@
     }
     port->gains.resize(halPort.num_gains);
     for (size_t i = 0; i < halPort.num_gains; ++i) {
-        audioGainFromHal(halPort.gains[i], &port->gains[i]);
+        audioGainFromHal(halPort.gains[i], false /*isInput--ignored*/, &port->gains[i]);
     }
     audioPortConfigFromHal(halPort.active_config, &port->activeConfig);
     switch (halPort.type) {
@@ -351,6 +353,18 @@
     return NO_ERROR;
 }
 
+#if MAJOR_VERSION >= 5
+status_t HidlUtils::deviceAddressToHal(const DeviceAddress& device, audio_devices_t* halDeviceType,
+                                       char* halDeviceAddress) {
+    return deviceAddressToHalImpl(device, halDeviceType, halDeviceAddress);
+}
+
+status_t HidlUtils::deviceAddressFromHal(audio_devices_t halDeviceType,
+                                         const char* halDeviceAddress, DeviceAddress* device) {
+    return deviceAddressFromHalImpl(halDeviceType, halDeviceAddress, device);
+}
+#endif
+
 }  // namespace implementation
 }  // namespace CPP_VERSION
 }  // namespace common
diff --git a/audio/common/all-versions/default/HidlUtils.h b/audio/common/all-versions/default/HidlUtils.h
index 4e609ca..a0bd1bc 100644
--- a/audio/common/all-versions/default/HidlUtils.h
+++ b/audio/common/all-versions/default/HidlUtils.h
@@ -23,8 +23,6 @@
 
 #include <system/audio.h>
 
-using ::android::hardware::hidl_vec;
-
 namespace android {
 namespace hardware {
 namespace audio {
@@ -32,25 +30,25 @@
 namespace CPP_VERSION {
 namespace implementation {
 
+using ::android::hardware::hidl_vec;
 using namespace ::android::hardware::audio::common::CPP_VERSION;
 
 struct HidlUtils {
-#if MAJOR_VERSION < 7
-    static status_t audioConfigFromHal(const audio_config_t& halConfig, AudioConfig* config);
-    static void audioGainConfigFromHal(const struct audio_gain_config& halConfig,
-                                       AudioGainConfig* config);
-    static void audioGainFromHal(const struct audio_gain& halGain, AudioGain* gain);
-#else
     static status_t audioConfigFromHal(const audio_config_t& halConfig, bool isInput,
                                        AudioConfig* config);
+    static status_t audioConfigToHal(const AudioConfig& config, audio_config_t* halConfig);
+#if MAJOR_VERSION >= 4
+    static status_t audioContentTypeFromHal(const audio_content_type_t halContentType,
+                                            AudioContentType* contentType);
+    static status_t audioContentTypeToHal(const AudioContentType& contentType,
+                                          audio_content_type_t* halContentType);
+#endif
     static status_t audioGainConfigFromHal(const struct audio_gain_config& halConfig, bool isInput,
                                            AudioGainConfig* config);
-    static status_t audioGainFromHal(const struct audio_gain& halGain, bool isInput,
-                                     AudioGain* gain);
-#endif
-    static status_t audioConfigToHal(const AudioConfig& config, audio_config_t* halConfig);
     static status_t audioGainConfigToHal(const AudioGainConfig& config,
                                          struct audio_gain_config* halConfig);
+    static status_t audioGainFromHal(const struct audio_gain& halGain, bool isInput,
+                                     AudioGain* gain);
     static status_t audioGainToHal(const AudioGain& gain, struct audio_gain* halGain);
     static status_t audioUsageFromHal(audio_usage_t halUsage, AudioUsage* usage);
     static status_t audioUsageToHal(const AudioUsage& usage, audio_usage_t* halUsage);
@@ -64,43 +62,25 @@
                                          struct audio_port_config* halConfig);
     static status_t audioPortConfigsFromHal(unsigned int numHalConfigs,
                                             const struct audio_port_config* halConfigs,
-                                            hidl_vec<AudioPortConfig>* configs) {
-        status_t result = NO_ERROR;
-        configs->resize(numHalConfigs);
-        for (unsigned int i = 0; i < numHalConfigs; ++i) {
-            if (status_t status = audioPortConfigFromHal(halConfigs[i], &(*configs)[i]);
-                status != NO_ERROR) {
-                result = status;
-            }
-        }
-        return result;
-    }
+                                            hidl_vec<AudioPortConfig>* configs);
     static status_t audioPortConfigsToHal(const hidl_vec<AudioPortConfig>& configs,
-                                          std::unique_ptr<audio_port_config[]>* halConfigs) {
-        status_t result = NO_ERROR;
-        halConfigs->reset(new audio_port_config[configs.size()]);
-        for (size_t i = 0; i < configs.size(); ++i) {
-            if (status_t status = audioPortConfigToHal(configs[i], &(*halConfigs)[i]);
-                status != NO_ERROR) {
-                result = status;
-            }
-        }
-        return result;
-    }
-
-    // PLEASE DO NOT USE, will be removed in a couple of days
-    static std::unique_ptr<audio_port_config[]> audioPortConfigsToHal(
-            const hidl_vec<AudioPortConfig>& configs) {
-        std::unique_ptr<audio_port_config[]> halConfigs;
-        (void)audioPortConfigsToHal(configs, &halConfigs);
-        return halConfigs;
-    }
-
+                                          std::unique_ptr<audio_port_config[]>* halConfigs);
     static status_t audioPortFromHal(const struct audio_port& halPort, AudioPort* port);
     static status_t audioPortToHal(const AudioPort& port, struct audio_port* halPort);
+    static status_t audioSourceFromHal(audio_source_t halSource, AudioSource* source);
+    static status_t audioSourceToHal(const AudioSource& source, audio_source_t* halSource);
+#if MAJOR_VERSION >= 5
+    static status_t deviceAddressToHal(const DeviceAddress& device, audio_devices_t* halDeviceType,
+                                       char* halDeviceAddress);
+    static status_t deviceAddressFromHal(audio_devices_t halDeviceType,
+                                         const char* halDeviceAddress, DeviceAddress* device);
+#endif
+
 #if MAJOR_VERSION >= 7
     static status_t audioChannelMaskFromHal(audio_channel_mask_t halChannelMask, bool isInput,
                                             AudioChannelMask* channelMask);
+    static status_t audioChannelMasksFromHal(const std::vector<std::string>& halChannelMasks,
+                                             hidl_vec<AudioChannelMask>* channelMasks);
     static status_t audioChannelMaskToHal(const AudioChannelMask& channelMask,
                                           audio_channel_mask_t* halChannelMask);
     static status_t audioConfigBaseFromHal(const audio_config_base_t& halConfigBase, bool isInput,
@@ -110,6 +90,8 @@
     static status_t audioDeviceTypeFromHal(audio_devices_t halDevice, AudioDevice* device);
     static status_t audioDeviceTypeToHal(const AudioDevice& device, audio_devices_t* halDevice);
     static status_t audioFormatFromHal(audio_format_t halFormat, AudioFormat* format);
+    static status_t audioFormatsFromHal(const std::vector<std::string>& halFormats,
+                                        hidl_vec<AudioFormat>* formats);
     static status_t audioFormatToHal(const AudioFormat& format, audio_format_t* halFormat);
     static status_t audioGainModeMaskFromHal(audio_gain_mode_t halGainModeMask,
                                              hidl_vec<AudioGainMode>* gainModeMask);
@@ -121,16 +103,10 @@
                                         AudioProfile* profile);
     static status_t audioProfileToHal(const AudioProfile& profile,
                                       struct audio_profile* halProfile);
-    static status_t audioSourceFromHal(audio_source_t halSource, AudioSource* source);
-    static status_t audioSourceToHal(const AudioSource& source, audio_source_t* halSource);
     static status_t audioStreamTypeFromHal(audio_stream_type_t halStreamType,
                                            AudioStreamType* streamType);
     static status_t audioStreamTypeToHal(const AudioStreamType& streamType,
                                          audio_stream_type_t* halStreamType);
-    static status_t deviceAddressToHal(const DeviceAddress& device, audio_devices_t* halDeviceType,
-                                       char* halDeviceAddress);
-    static status_t deviceAddressFromHal(audio_devices_t halDeviceType,
-                                         const char* halDeviceAddress, DeviceAddress* device);
 
   private:
     static status_t audioIndexChannelMaskFromHal(audio_channel_mask_t halChannelMask,
@@ -150,9 +126,114 @@
                                                struct audio_port_config_device_ext* device,
                                                struct audio_port_config_mix_ext* mix,
                                                struct audio_port_config_session_ext* session);
+#endif  // MAJOR_VERSION >= 7
+
+    // V4 and below have DeviceAddress defined in the 'core' interface.
+    // To avoid duplicating code, the implementations of deviceAddressTo/FromHal
+    // are defined as templates. These templates can be only used directly by V4
+    // and below.
+#if MAJOR_VERSION >= 5
+  private:
 #endif
+    template <typename DA>
+    static status_t deviceAddressToHalImpl(const DA& device, audio_devices_t* halDeviceType,
+                                           char* halDeviceAddress);
+    template <typename DA>
+    static status_t deviceAddressFromHalImpl(audio_devices_t halDeviceType,
+                                             const char* halDeviceAddress, DA* device);
 };
 
+#if MAJOR_VERSION <= 6
+#if MAJOR_VERSION >= 4
+inline status_t HidlUtils::audioContentTypeFromHal(const audio_content_type_t halContentType,
+                                                   AudioContentType* contentType) {
+    *contentType = AudioContentType(halContentType);
+    return NO_ERROR;
+}
+
+inline status_t HidlUtils::audioContentTypeToHal(const AudioContentType& contentType,
+                                                 audio_content_type_t* halContentType) {
+    *halContentType = static_cast<audio_content_type_t>(contentType);
+    return NO_ERROR;
+}
+#endif
+
+inline status_t HidlUtils::audioSourceFromHal(audio_source_t halSource, AudioSource* source) {
+    *source = AudioSource(halSource);
+    return NO_ERROR;
+}
+
+inline status_t HidlUtils::audioSourceToHal(const AudioSource& source, audio_source_t* halSource) {
+    *halSource = static_cast<audio_source_t>(source);
+    return NO_ERROR;
+}
+
+template <typename DA>
+status_t HidlUtils::deviceAddressToHalImpl(const DA& device, audio_devices_t* halDeviceType,
+                                           char* halDeviceAddress) {
+    *halDeviceType = static_cast<audio_devices_t>(device.device);
+    memset(halDeviceAddress, 0, AUDIO_DEVICE_MAX_ADDRESS_LEN);
+    if (audio_is_a2dp_out_device(*halDeviceType) || audio_is_a2dp_in_device(*halDeviceType)) {
+        snprintf(halDeviceAddress, AUDIO_DEVICE_MAX_ADDRESS_LEN, "%02X:%02X:%02X:%02X:%02X:%02X",
+                 device.address.mac[0], device.address.mac[1], device.address.mac[2],
+                 device.address.mac[3], device.address.mac[4], device.address.mac[5]);
+    } else if (*halDeviceType == AUDIO_DEVICE_OUT_IP || *halDeviceType == AUDIO_DEVICE_IN_IP) {
+        snprintf(halDeviceAddress, AUDIO_DEVICE_MAX_ADDRESS_LEN, "%d.%d.%d.%d",
+                 device.address.ipv4[0], device.address.ipv4[1], device.address.ipv4[2],
+                 device.address.ipv4[3]);
+    } else if (audio_is_usb_out_device(*halDeviceType) || audio_is_usb_in_device(*halDeviceType)) {
+        snprintf(halDeviceAddress, AUDIO_DEVICE_MAX_ADDRESS_LEN, "card=%d;device=%d",
+                 device.address.alsa.card, device.address.alsa.device);
+    } else if (*halDeviceType == AUDIO_DEVICE_OUT_BUS || *halDeviceType == AUDIO_DEVICE_IN_BUS) {
+        snprintf(halDeviceAddress, AUDIO_DEVICE_MAX_ADDRESS_LEN, "%s", device.busAddress.c_str());
+    } else if (*halDeviceType == AUDIO_DEVICE_OUT_REMOTE_SUBMIX ||
+               *halDeviceType == AUDIO_DEVICE_IN_REMOTE_SUBMIX) {
+        snprintf(halDeviceAddress, AUDIO_DEVICE_MAX_ADDRESS_LEN, "%s",
+                 device.rSubmixAddress.c_str());
+    }
+    return NO_ERROR;
+}
+
+template <typename DA>
+status_t HidlUtils::deviceAddressFromHalImpl(audio_devices_t halDeviceType,
+                                             const char* halDeviceAddress, DA* device) {
+    if (device == nullptr) {
+        return BAD_VALUE;
+    }
+    device->device = AudioDevice(halDeviceType);
+    if (halDeviceAddress == nullptr ||
+        strnlen(halDeviceAddress, AUDIO_DEVICE_MAX_ADDRESS_LEN) == 0) {
+        return NO_ERROR;
+    }
+
+    if (audio_is_a2dp_out_device(halDeviceType) || audio_is_a2dp_in_device(halDeviceType)) {
+        int status =
+                sscanf(halDeviceAddress, "%hhX:%hhX:%hhX:%hhX:%hhX:%hhX", &device->address.mac[0],
+                       &device->address.mac[1], &device->address.mac[2], &device->address.mac[3],
+                       &device->address.mac[4], &device->address.mac[5]);
+        return status == 6 ? OK : BAD_VALUE;
+    } else if (halDeviceType == AUDIO_DEVICE_OUT_IP || halDeviceType == AUDIO_DEVICE_IN_IP) {
+        int status = sscanf(halDeviceAddress, "%hhu.%hhu.%hhu.%hhu", &device->address.ipv4[0],
+                            &device->address.ipv4[1], &device->address.ipv4[2],
+                            &device->address.ipv4[3]);
+        return status == 4 ? OK : BAD_VALUE;
+    } else if (audio_is_usb_out_device(halDeviceType) || audio_is_usb_in_device(halDeviceType)) {
+        int status = sscanf(halDeviceAddress, "card=%d;device=%d", &device->address.alsa.card,
+                            &device->address.alsa.device);
+        return status == 2 ? OK : BAD_VALUE;
+    } else if (halDeviceType == AUDIO_DEVICE_OUT_BUS || halDeviceType == AUDIO_DEVICE_IN_BUS) {
+        device->busAddress = halDeviceAddress;
+        return OK;
+    } else if (halDeviceType == AUDIO_DEVICE_OUT_REMOTE_SUBMIX ||
+               halDeviceType == AUDIO_DEVICE_IN_REMOTE_SUBMIX) {
+        device->rSubmixAddress = halDeviceAddress;
+        return OK;
+    }
+    device->busAddress = halDeviceAddress;
+    return NO_ERROR;
+}
+#endif  // MAJOR_VERSION <= 6
+
 }  // namespace implementation
 }  // namespace CPP_VERSION
 }  // namespace common
diff --git a/audio/common/all-versions/default/HidlUtilsCommon.cpp b/audio/common/all-versions/default/HidlUtilsCommon.cpp
new file mode 100644
index 0000000..d2da193
--- /dev/null
+++ b/audio/common/all-versions/default/HidlUtilsCommon.cpp
@@ -0,0 +1,58 @@
+/*
+ * 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 "HidlUtils.h"
+
+namespace android {
+namespace hardware {
+namespace audio {
+namespace common {
+namespace CPP_VERSION {
+namespace implementation {
+
+status_t HidlUtils::audioPortConfigsFromHal(unsigned int numHalConfigs,
+                                            const struct audio_port_config* halConfigs,
+                                            hidl_vec<AudioPortConfig>* configs) {
+    status_t result = NO_ERROR;
+    configs->resize(numHalConfigs);
+    for (unsigned int i = 0; i < numHalConfigs; ++i) {
+        if (status_t status = audioPortConfigFromHal(halConfigs[i], &(*configs)[i]);
+            status != NO_ERROR) {
+            result = status;
+        }
+    }
+    return result;
+}
+
+status_t HidlUtils::audioPortConfigsToHal(const hidl_vec<AudioPortConfig>& configs,
+                                          std::unique_ptr<audio_port_config[]>* halConfigs) {
+    status_t result = NO_ERROR;
+    halConfigs->reset(new audio_port_config[configs.size()]);
+    for (size_t i = 0; i < configs.size(); ++i) {
+        if (status_t status = audioPortConfigToHal(configs[i], &(*halConfigs)[i]);
+            status != NO_ERROR) {
+            result = status;
+        }
+    }
+    return result;
+}
+
+}  // namespace implementation
+}  // namespace CPP_VERSION
+}  // namespace common
+}  // namespace audio
+}  // namespace hardware
+}  // namespace android
diff --git a/audio/common/all-versions/default/tests/hidlutils_tests.cpp b/audio/common/all-versions/default/tests/hidlutils_tests.cpp
index bfc99e6..22571c0 100644
--- a/audio/common/all-versions/default/tests/hidlutils_tests.cpp
+++ b/audio/common/all-versions/default/tests/hidlutils_tests.cpp
@@ -28,6 +28,7 @@
 #include <xsdc/XsdcSupport.h>
 
 using namespace android;
+using ::android::hardware::hidl_vec;
 using namespace ::android::hardware::audio::common::CPP_VERSION;
 using ::android::hardware::audio::common::CPP_VERSION::implementation::HidlUtils;
 namespace xsd {
@@ -36,6 +37,8 @@
 
 static constexpr audio_channel_mask_t kInvalidHalChannelMask =
         static_cast<audio_channel_mask_t>(0xFFFFFFFFU);
+static constexpr audio_content_type_t kInvalidHalContentType =
+        static_cast<audio_content_type_t>(0xFFFFFFFFU);
 static constexpr audio_devices_t kInvalidHalDevice = static_cast<audio_devices_t>(0xFFFFFFFFU);
 static constexpr audio_format_t kInvalidHalFormat = static_cast<audio_format_t>(0xFFFFFFFFU);
 static constexpr audio_gain_mode_t kInvalidHalGainMode =
@@ -117,6 +120,34 @@
     }
 }
 
+TEST(HidlUtils, ConvertInvalidChannelMasksFromHal) {
+    std::vector<std::string> validAndInvalidChannelMasks = {
+            toString(xsd::AudioChannelMask::AUDIO_CHANNEL_OUT_STEREO), "random string", ""};
+    hidl_vec<AudioChannelMask> validChannelMask;
+    EXPECT_EQ(BAD_VALUE,
+              HidlUtils::audioChannelMasksFromHal(validAndInvalidChannelMasks, &validChannelMask));
+    EXPECT_EQ(1, validChannelMask.size());
+    EXPECT_EQ(validAndInvalidChannelMasks[0], validChannelMask[0]);
+
+    std::vector<std::string> invalidChannelMasks = {"random string", ""};
+    hidl_vec<AudioChannelMask> empty;
+    EXPECT_EQ(BAD_VALUE, HidlUtils::audioChannelMasksFromHal(invalidChannelMasks, &empty));
+    EXPECT_EQ(0, empty.size());
+}
+
+TEST(HidlUtils, ConvertChannelMasksFromHal) {
+    std::vector<std::string> allHalChannelMasks;
+    for (const auto enumVal : xsdc_enum_range<xsd::AudioChannelMask>{}) {
+        allHalChannelMasks.push_back(toString(enumVal));
+    }
+    hidl_vec<AudioChannelMask> allChannelMasks;
+    EXPECT_EQ(NO_ERROR, HidlUtils::audioChannelMasksFromHal(allHalChannelMasks, &allChannelMasks));
+    EXPECT_EQ(allHalChannelMasks.size(), allChannelMasks.size());
+    for (size_t i = 0; i < allHalChannelMasks.size(); ++i) {
+        EXPECT_EQ(allHalChannelMasks[i], allChannelMasks[i]);
+    }
+}
+
 TEST(HidlUtils, ConvertInvalidConfigBase) {
     AudioConfigBase invalid;
     EXPECT_EQ(BAD_VALUE, HidlUtils::audioConfigBaseFromHal({.sample_rate = 0,
@@ -147,6 +178,26 @@
     EXPECT_EQ(configBase, configBaseBack);
 }
 
+TEST(HidlUtils, ConvertInvalidContentType) {
+    AudioContentType invalid;
+    EXPECT_EQ(BAD_VALUE, HidlUtils::audioContentTypeFromHal(kInvalidHalContentType, &invalid));
+    audio_content_type_t halInvalid;
+    EXPECT_EQ(BAD_VALUE, HidlUtils::audioContentTypeToHal("random string", &halInvalid));
+}
+
+TEST(HidlUtils, ConvertContentType) {
+    for (const auto enumVal : xsdc_enum_range<xsd::AudioContentType>{}) {
+        const AudioContentType contentType = toString(enumVal);
+        audio_content_type_t halContentType;
+        AudioContentType contentTypeBack;
+        EXPECT_EQ(NO_ERROR, HidlUtils::audioContentTypeToHal(contentType, &halContentType))
+                << "Conversion of \"" << contentType << "\" failed";
+        EXPECT_EQ(NO_ERROR, HidlUtils::audioContentTypeFromHal(halContentType, &contentTypeBack))
+                << "Conversion of content type " << halContentType << " failed";
+        EXPECT_EQ(contentType, contentTypeBack);
+    }
+}
+
 TEST(HidlUtils, ConvertInvalidDeviceType) {
     AudioDevice invalid;
     EXPECT_EQ(BAD_VALUE, HidlUtils::audioDeviceTypeFromHal(kInvalidHalDevice, &invalid));
@@ -314,6 +365,33 @@
     }
 }
 
+TEST(HidlUtils, ConvertInvalidFormatsFromHal) {
+    std::vector<std::string> validAndInvalidFormats = {
+            toString(xsd::AudioFormat::AUDIO_FORMAT_PCM_16_BIT), "random string", ""};
+    hidl_vec<AudioFormat> validFormat;
+    EXPECT_EQ(BAD_VALUE, HidlUtils::audioFormatsFromHal(validAndInvalidFormats, &validFormat));
+    EXPECT_EQ(1, validFormat.size());
+    EXPECT_EQ(validAndInvalidFormats[0], validFormat[0]);
+
+    std::vector<std::string> invalidFormats = {"random string", ""};
+    hidl_vec<AudioFormat> empty;
+    EXPECT_EQ(BAD_VALUE, HidlUtils::audioFormatsFromHal(invalidFormats, &empty));
+    EXPECT_EQ(0, empty.size());
+}
+
+TEST(HidlUtils, ConvertFormatsFromHal) {
+    std::vector<std::string> allHalFormats;
+    for (const auto enumVal : xsdc_enum_range<xsd::AudioFormat>{}) {
+        allHalFormats.push_back(toString(enumVal));
+    }
+    hidl_vec<AudioFormat> allFormats;
+    EXPECT_EQ(NO_ERROR, HidlUtils::audioFormatsFromHal(allHalFormats, &allFormats));
+    EXPECT_EQ(allHalFormats.size(), allFormats.size());
+    for (size_t i = 0; i < allHalFormats.size(); ++i) {
+        EXPECT_EQ(allHalFormats[i], allFormats[i]);
+    }
+}
+
 TEST(HidlUtils, ConvertInvalidGainModeMask) {
     hidl_vec<AudioGainMode> invalid;
     EXPECT_EQ(BAD_VALUE, HidlUtils::audioGainModeMaskFromHal(kInvalidHalGainMode, &invalid));
diff --git a/audio/core/all-versions/default/Android.bp b/audio/core/all-versions/default/Android.bp
index 6be0628..e0f0860 100644
--- a/audio/core/all-versions/default/Android.bp
+++ b/audio/core/all-versions/default/Android.bp
@@ -125,13 +125,15 @@
 }
 
 cc_library_shared {
-    enabled: false,
     name: "android.hardware.audio@7.0-impl",
     defaults: ["android.hardware.audio-impl_default"],
     shared_libs: [
         "android.hardware.audio@7.0",
         "android.hardware.audio.common@7.0",
+        "android.hardware.audio.common@7.0-enums",
         "android.hardware.audio.common@7.0-util",
+        "libbase",
+        "libxml2",
     ],
     cflags: [
         "-DMAJOR_VERSION=7",
diff --git a/audio/core/all-versions/default/Conversions.cpp b/audio/core/all-versions/default/Conversions.cpp
index 28d8f78..8e0a140 100644
--- a/audio/core/all-versions/default/Conversions.cpp
+++ b/audio/core/all-versions/default/Conversions.cpp
@@ -18,8 +18,11 @@
 
 #include <stdio.h>
 
+#if MAJOR_VERSION >= 7
+#include <android_audio_policy_configuration_V7_0-enums.h>
+#endif
+#include <HidlUtils.h>
 #include <log/log.h>
-#include <media/AudioContainers.h>
 
 namespace android {
 namespace hardware {
@@ -27,73 +30,36 @@
 namespace CPP_VERSION {
 namespace implementation {
 
-// TODO(mnaganov): Use method from HidlUtils for V7
+using ::android::hardware::audio::common::CPP_VERSION::implementation::HidlUtils;
+
+#if MAJOR_VERSION <= 6
 std::string deviceAddressToHal(const DeviceAddress& address) {
-    // HAL assumes that the address is NUL-terminated.
+    audio_devices_t halDevice;
     char halAddress[AUDIO_DEVICE_MAX_ADDRESS_LEN];
-    memset(halAddress, 0, sizeof(halAddress));
-    audio_devices_t halDevice = static_cast<audio_devices_t>(address.device);
-    if (getAudioDeviceOutAllA2dpSet().count(halDevice) > 0 ||
-        halDevice == AUDIO_DEVICE_IN_BLUETOOTH_A2DP) {
-        snprintf(halAddress, sizeof(halAddress), "%02X:%02X:%02X:%02X:%02X:%02X",
-                 address.address.mac[0], address.address.mac[1], address.address.mac[2],
-                 address.address.mac[3], address.address.mac[4], address.address.mac[5]);
-    } else if (halDevice == AUDIO_DEVICE_OUT_IP || halDevice == AUDIO_DEVICE_IN_IP) {
-        snprintf(halAddress, sizeof(halAddress), "%d.%d.%d.%d", address.address.ipv4[0],
-                 address.address.ipv4[1], address.address.ipv4[2], address.address.ipv4[3]);
-    } else if (getAudioDeviceOutAllUsbSet().count(halDevice) > 0 ||
-               getAudioDeviceInAllUsbSet().count(halDevice) > 0) {
-        snprintf(halAddress, sizeof(halAddress), "card=%d;device=%d", address.address.alsa.card,
-                 address.address.alsa.device);
-    } else if (halDevice == AUDIO_DEVICE_OUT_BUS || halDevice == AUDIO_DEVICE_IN_BUS) {
-        snprintf(halAddress, sizeof(halAddress), "%s", address.busAddress.c_str());
-    } else if (halDevice == AUDIO_DEVICE_OUT_REMOTE_SUBMIX ||
-               halDevice == AUDIO_DEVICE_IN_REMOTE_SUBMIX) {
-        snprintf(halAddress, sizeof(halAddress), "%s", address.rSubmixAddress.c_str());
-    }
+    (void)deviceAddressToHal(address, &halDevice, halAddress);
     return halAddress;
 }
+#endif
+
+status_t deviceAddressToHal(const DeviceAddress& device, audio_devices_t* halDeviceType,
+                            char* halDeviceAddress) {
+#if MAJOR_VERSION >= 5
+    return HidlUtils::deviceAddressToHal(device, halDeviceType, halDeviceAddress);
+#else
+    return HidlUtils::deviceAddressToHalImpl(device, halDeviceType, halDeviceAddress);
+#endif
+}
+
+status_t deviceAddressFromHal(audio_devices_t halDeviceType, const char* halDeviceAddress,
+                              DeviceAddress* device) {
+#if MAJOR_VERSION >= 5
+    return HidlUtils::deviceAddressFromHal(halDeviceType, halDeviceAddress, device);
+#else
+    return HidlUtils::deviceAddressFromHalImpl(halDeviceType, halDeviceAddress, device);
+#endif
+}
 
 #if MAJOR_VERSION >= 4
-status_t deviceAddressFromHal(audio_devices_t device, const char* halAddress,
-                              DeviceAddress* address) {
-    if (address == nullptr) {
-        return BAD_VALUE;
-    }
-    address->device = AudioDevice(device);
-    if (halAddress == nullptr || strnlen(halAddress, AUDIO_DEVICE_MAX_ADDRESS_LEN) == 0) {
-        return OK;
-    }
-
-    if (getAudioDeviceOutAllA2dpSet().count(device) > 0 ||
-        device == AUDIO_DEVICE_IN_BLUETOOTH_A2DP) {
-        int status =
-            sscanf(halAddress, "%hhX:%hhX:%hhX:%hhX:%hhX:%hhX", &address->address.mac[0],
-                   &address->address.mac[1], &address->address.mac[2], &address->address.mac[3],
-                   &address->address.mac[4], &address->address.mac[5]);
-        return status == 6 ? OK : BAD_VALUE;
-    } else if (device == AUDIO_DEVICE_OUT_IP || device == AUDIO_DEVICE_IN_IP) {
-        int status =
-            sscanf(halAddress, "%hhu.%hhu.%hhu.%hhu", &address->address.ipv4[0],
-                   &address->address.ipv4[1], &address->address.ipv4[2], &address->address.ipv4[3]);
-        return status == 4 ? OK : BAD_VALUE;
-    } else if (getAudioDeviceOutAllUsbSet().count(device) > 0 ||
-               getAudioDeviceInAllUsbSet().count(device) > 0) {
-        int status = sscanf(halAddress, "card=%d;device=%d", &address->address.alsa.card,
-                            &address->address.alsa.device);
-        return status == 2 ? OK : BAD_VALUE;
-    } else if (device == AUDIO_DEVICE_OUT_BUS || device == AUDIO_DEVICE_IN_BUS) {
-        address->busAddress = halAddress;
-        return OK;
-    } else if (device == AUDIO_DEVICE_OUT_REMOTE_SUBMIX ||
-               device == AUDIO_DEVICE_IN_REMOTE_SUBMIX) {
-        address->rSubmixAddress = halAddress;
-        return OK;
-    }
-    address->busAddress = halAddress;
-    return OK;
-}
-
 bool halToMicrophoneCharacteristics(MicrophoneInfo* pDst,
                                     const struct audio_microphone_characteristic_t& src) {
     bool status = false;
@@ -131,6 +97,44 @@
     }
     return status;
 }
+#endif  // MAJOR_VERSION >= 4
+
+#if MAJOR_VERSION >= 7
+namespace xsd {
+using namespace ::android::audio::policy::configuration::V7_0;
+}
+
+bool audioInputFlagsToHal(const hidl_vec<AudioInOutFlag>& flags, audio_input_flags_t* halFlags) {
+    bool success = true;
+    *halFlags = {};
+    for (const auto& flag : flags) {
+        audio_input_flags_t halFlag;
+        if (!xsd::isUnknownAudioInOutFlag(flag) &&
+            audio_input_flag_from_string(flag.c_str(), &halFlag)) {
+            *halFlags = static_cast<audio_input_flags_t>(*halFlags | halFlag);
+        } else {
+            ALOGE("Unknown audio input flag \"%s\"", flag.c_str());
+            success = false;
+        }
+    }
+    return success;
+}
+
+bool audioOutputFlagsToHal(const hidl_vec<AudioInOutFlag>& flags, audio_output_flags_t* halFlags) {
+    bool success = true;
+    *halFlags = {};
+    for (const auto& flag : flags) {
+        audio_output_flags_t halFlag;
+        if (!xsd::isUnknownAudioInOutFlag(flag) &&
+            audio_output_flag_from_string(flag.c_str(), &halFlag)) {
+            *halFlags = static_cast<audio_output_flags_t>(*halFlags | halFlag);
+        } else {
+            ALOGE("Unknown audio output flag \"%s\"", flag.c_str());
+            success = false;
+        }
+    }
+    return success;
+}
 #endif
 
 }  // namespace implementation
diff --git a/audio/core/all-versions/default/Device.cpp b/audio/core/all-versions/default/Device.cpp
index 3c28159..bb69f0b 100644
--- a/audio/core/all-versions/default/Device.cpp
+++ b/audio/core/all-versions/default/Device.cpp
@@ -150,63 +150,76 @@
 std::tuple<Result, sp<IStreamOut>> Device::openOutputStreamImpl(int32_t ioHandle,
                                                                 const DeviceAddress& device,
                                                                 const AudioConfig& config,
-                                                                AudioOutputFlagBitfield flags,
+                                                                const AudioOutputFlags& flags,
                                                                 AudioConfig* suggestedConfig) {
     audio_config_t halConfig;
     HidlUtils::audioConfigToHal(config, &halConfig);
     audio_stream_out_t* halStream;
-    ALOGV(
-        "open_output_stream handle: %d devices: %x flags: %#x "
-        "srate: %d format %#x channels %x address %s",
-        ioHandle, static_cast<audio_devices_t>(device.device),
-        static_cast<audio_output_flags_t>(flags), halConfig.sample_rate, halConfig.format,
-        halConfig.channel_mask, deviceAddressToHal(device).c_str());
-    int status =
-        mDevice->open_output_stream(mDevice, ioHandle, static_cast<audio_devices_t>(device.device),
-                                    static_cast<audio_output_flags_t>(flags), &halConfig,
-                                    &halStream, deviceAddressToHal(device).c_str());
+    audio_devices_t halDevice;
+    char halDeviceAddress[AUDIO_DEVICE_MAX_ADDRESS_LEN];
+    if (deviceAddressToHal(device, &halDevice, halDeviceAddress) != NO_ERROR) {
+        return {Result::INVALID_ARGUMENTS, nullptr};
+    }
+    audio_output_flags_t halFlags;
+    if (!audioOutputFlagsToHal(flags, &halFlags)) {
+        return {Result::INVALID_ARGUMENTS, nullptr};
+    }
+    ALOGV("open_output_stream handle: %d devices: %x flags: %#x "
+          "srate: %d format %#x channels %x address %s",
+          ioHandle, halDevice, halFlags, halConfig.sample_rate, halConfig.format,
+          halConfig.channel_mask, halDeviceAddress);
+    int status = mDevice->open_output_stream(mDevice, ioHandle, halDevice, halFlags, &halConfig,
+                                             &halStream, halDeviceAddress);
     ALOGV("open_output_stream status %d stream %p", status, halStream);
     sp<IStreamOut> streamOut;
     if (status == OK) {
         streamOut = new StreamOut(this, halStream);
         ++mOpenedStreamsCount;
     }
-    status_t convertStatus = HidlUtils::audioConfigFromHal(halConfig, suggestedConfig);
+    status_t convertStatus =
+            HidlUtils::audioConfigFromHal(halConfig, false /*isInput*/, suggestedConfig);
     ALOGW_IF(convertStatus != OK, "%s: suggested config with incompatible fields", __func__);
     return {analyzeStatus("open_output_stream", status, {EINVAL} /*ignore*/), streamOut};
 }
 
 std::tuple<Result, sp<IStreamIn>> Device::openInputStreamImpl(
-    int32_t ioHandle, const DeviceAddress& device, const AudioConfig& config,
-    AudioInputFlagBitfield flags, AudioSource source, AudioConfig* suggestedConfig) {
+        int32_t ioHandle, const DeviceAddress& device, const AudioConfig& config,
+        const AudioInputFlags& flags, AudioSource source, AudioConfig* suggestedConfig) {
     audio_config_t halConfig;
     HidlUtils::audioConfigToHal(config, &halConfig);
     audio_stream_in_t* halStream;
-    ALOGV(
-        "open_input_stream handle: %d devices: %x flags: %#x "
-        "srate: %d format %#x channels %x address %s source %d",
-        ioHandle, static_cast<audio_devices_t>(device.device),
-        static_cast<audio_input_flags_t>(flags), halConfig.sample_rate, halConfig.format,
-        halConfig.channel_mask, deviceAddressToHal(device).c_str(),
-        static_cast<audio_source_t>(source));
-    int status = mDevice->open_input_stream(
-        mDevice, ioHandle, static_cast<audio_devices_t>(device.device), &halConfig, &halStream,
-        static_cast<audio_input_flags_t>(flags), deviceAddressToHal(device).c_str(),
-        static_cast<audio_source_t>(source));
+    audio_devices_t halDevice;
+    char halDeviceAddress[AUDIO_DEVICE_MAX_ADDRESS_LEN];
+    if (deviceAddressToHal(device, &halDevice, halDeviceAddress) != NO_ERROR) {
+        return {Result::INVALID_ARGUMENTS, nullptr};
+    }
+    audio_input_flags_t halFlags;
+    audio_source_t halSource;
+    if (!audioInputFlagsToHal(flags, &halFlags) ||
+        HidlUtils::audioSourceToHal(source, &halSource) != NO_ERROR) {
+        return {Result::INVALID_ARGUMENTS, nullptr};
+    }
+    ALOGV("open_input_stream handle: %d devices: %x flags: %#x "
+          "srate: %d format %#x channels %x address %s source %d",
+          ioHandle, halDevice, halFlags, halConfig.sample_rate, halConfig.format,
+          halConfig.channel_mask, halDeviceAddress, halSource);
+    int status = mDevice->open_input_stream(mDevice, ioHandle, halDevice, &halConfig, &halStream,
+                                            halFlags, halDeviceAddress, halSource);
     ALOGV("open_input_stream status %d stream %p", status, halStream);
     sp<IStreamIn> streamIn;
     if (status == OK) {
         streamIn = new StreamIn(this, halStream);
         ++mOpenedStreamsCount;
     }
-    status_t convertStatus = HidlUtils::audioConfigFromHal(halConfig, suggestedConfig);
+    status_t convertStatus =
+            HidlUtils::audioConfigFromHal(halConfig, true /*isInput*/, suggestedConfig);
     ALOGW_IF(convertStatus != OK, "%s: suggested config with incompatible fields", __func__);
     return {analyzeStatus("open_input_stream", status, {EINVAL} /*ignore*/), streamIn};
 }
 
 #if MAJOR_VERSION == 2
 Return<void> Device::openOutputStream(int32_t ioHandle, const DeviceAddress& device,
-                                      const AudioConfig& config, AudioOutputFlagBitfield flags,
+                                      const AudioConfig& config, AudioOutputFlags flags,
                                       openOutputStream_cb _hidl_cb) {
     AudioConfig suggestedConfig;
     auto [result, streamOut] =
@@ -216,7 +229,7 @@
 }
 
 Return<void> Device::openInputStream(int32_t ioHandle, const DeviceAddress& device,
-                                     const AudioConfig& config, AudioInputFlagBitfield flags,
+                                     const AudioConfig& config, AudioInputFlags flags,
                                      AudioSource source, openInputStream_cb _hidl_cb) {
     AudioConfig suggestedConfig;
     auto [result, streamIn] =
@@ -227,7 +240,12 @@
 
 #elif MAJOR_VERSION >= 4
 Return<void> Device::openOutputStream(int32_t ioHandle, const DeviceAddress& device,
-                                      const AudioConfig& config, AudioOutputFlagBitfield flags,
+                                      const AudioConfig& config,
+#if MAJOR_VERSION <= 6
+                                      AudioOutputFlags flags,
+#else
+                                      const AudioOutputFlags& flags,
+#endif
                                       const SourceMetadata& sourceMetadata,
                                       openOutputStream_cb _hidl_cb) {
     AudioConfig suggestedConfig;
@@ -241,7 +259,12 @@
 }
 
 Return<void> Device::openInputStream(int32_t ioHandle, const DeviceAddress& device,
-                                     const AudioConfig& config, AudioInputFlagBitfield flags,
+                                     const AudioConfig& config,
+#if MAJOR_VERSION <= 6
+                                     AudioInputFlags flags,
+#else
+                                     const AudioInputFlags& flags,
+#endif
                                      const SinkMetadata& sinkMetadata,
                                      openInputStream_cb _hidl_cb) {
     if (sinkMetadata.tracks.size() == 0) {
@@ -271,9 +294,7 @@
 Return<void> Device::createAudioPatch(const hidl_vec<AudioPortConfig>& sources,
                                       const hidl_vec<AudioPortConfig>& sinks,
                                       createAudioPatch_cb _hidl_cb) {
-    auto [retval, patch] = createOrUpdateAudioPatch(
-            static_cast<AudioPatchHandle>(AudioHandleConsts::AUDIO_PATCH_HANDLE_NONE), sources,
-            sinks);
+    auto [retval, patch] = createOrUpdateAudioPatch(AudioPatchHandle{}, sources, sinks);
     _hidl_cb(retval, patch);
     return Void();
 }
@@ -454,7 +475,7 @@
                                       const hidl_vec<AudioPortConfig>& sources,
                                       const hidl_vec<AudioPortConfig>& sinks,
                                       createAudioPatch_cb _hidl_cb) {
-    if (previousPatch != static_cast<int32_t>(AudioHandleConsts::AUDIO_PATCH_HANDLE_NONE)) {
+    if (previousPatch != static_cast<int32_t>(AudioPatchHandle{})) {
         auto [retval, patch] = createOrUpdateAudioPatch(previousPatch, sources, sinks);
         _hidl_cb(retval, patch);
     } else {
diff --git a/audio/core/all-versions/default/ParametersUtil.cpp b/audio/core/all-versions/default/ParametersUtil.cpp
index 0c8e28a..694eb73 100644
--- a/audio/core/all-versions/default/ParametersUtil.cpp
+++ b/audio/core/all-versions/default/ParametersUtil.cpp
@@ -149,9 +149,15 @@
     }
     return setParams(params);
 }
+
 Result ParametersUtil::setParam(const char* name, const DeviceAddress& address) {
-    AudioParameter params(String8(deviceAddressToHal(address).c_str()));
-    params.addInt(String8(name), int(address.device));
+    audio_devices_t halDeviceType;
+    char halDeviceAddress[AUDIO_DEVICE_MAX_ADDRESS_LEN];
+    if (deviceAddressToHal(address, &halDeviceType, halDeviceAddress) != NO_ERROR) {
+        return Result::INVALID_ARGUMENTS;
+    }
+    AudioParameter params{String8(halDeviceAddress)};
+    params.addInt(String8(name), halDeviceType);
     return setParams(params);
 }
 
diff --git a/audio/core/all-versions/default/PrimaryDevice.cpp b/audio/core/all-versions/default/PrimaryDevice.cpp
index 11c1c5a..fe56177 100644
--- a/audio/core/all-versions/default/PrimaryDevice.cpp
+++ b/audio/core/all-versions/default/PrimaryDevice.cpp
@@ -73,28 +73,36 @@
 
 #if MAJOR_VERSION == 2
 Return<void> PrimaryDevice::openOutputStream(int32_t ioHandle, const DeviceAddress& device,
-                                             const AudioConfig& config,
-                                             AudioOutputFlagBitfield flags,
+                                             const AudioConfig& config, AudioOutputFlags flags,
                                              openOutputStream_cb _hidl_cb) {
     return mDevice->openOutputStream(ioHandle, device, config, flags, _hidl_cb);
 }
 
 Return<void> PrimaryDevice::openInputStream(int32_t ioHandle, const DeviceAddress& device,
-                                            const AudioConfig& config, AudioInputFlagBitfield flags,
+                                            const AudioConfig& config, AudioInputFlags flags,
                                             AudioSource source, openInputStream_cb _hidl_cb) {
     return mDevice->openInputStream(ioHandle, device, config, flags, source, _hidl_cb);
 }
 #elif MAJOR_VERSION >= 4
 Return<void> PrimaryDevice::openOutputStream(int32_t ioHandle, const DeviceAddress& device,
                                              const AudioConfig& config,
-                                             AudioOutputFlagBitfield flags,
+#if MAJOR_VERSION <= 6
+                                             AudioOutputFlags flags,
+#else
+                                             const AudioOutputFlags& flags,
+#endif
                                              const SourceMetadata& sourceMetadata,
                                              openOutputStream_cb _hidl_cb) {
     return mDevice->openOutputStream(ioHandle, device, config, flags, sourceMetadata, _hidl_cb);
 }
 
 Return<void> PrimaryDevice::openInputStream(int32_t ioHandle, const DeviceAddress& device,
-                                            const AudioConfig& config, AudioInputFlagBitfield flags,
+                                            const AudioConfig& config,
+#if MAJOR_VERSION <= 6
+                                            AudioInputFlags flags,
+#else
+                                            const AudioInputFlags& flags,
+#endif
                                             const SinkMetadata& sinkMetadata,
                                             openInputStream_cb _hidl_cb) {
     return mDevice->openInputStream(ioHandle, device, config, flags, sinkMetadata, _hidl_cb);
diff --git a/audio/core/all-versions/default/Stream.cpp b/audio/core/all-versions/default/Stream.cpp
index 74e5945..c74079d 100644
--- a/audio/core/all-versions/default/Stream.cpp
+++ b/audio/core/all-versions/default/Stream.cpp
@@ -23,6 +23,7 @@
 
 #include <inttypes.h>
 
+#include <HidlUtils.h>
 #include <android/log.h>
 #include <hardware/audio.h>
 #include <hardware/audio_effect.h>
@@ -35,7 +36,11 @@
 namespace CPP_VERSION {
 namespace implementation {
 
-Stream::Stream(audio_stream_t* stream) : mStream(stream) {}
+using ::android::hardware::audio::common::CPP_VERSION::implementation::HidlUtils;
+
+Stream::Stream(bool isInput, audio_stream_t* stream) : mIsInput(isInput), mStream(stream) {
+    (void)mIsInput;  // prevent 'unused field' warnings in pre-V7 versions.
+}
 
 Stream::~Stream() {
     mStream = nullptr;
@@ -78,6 +83,7 @@
     return mStream->get_buffer_size(mStream);
 }
 
+#if MAJOR_VERSION <= 6
 Return<uint32_t> Stream::getSampleRate() {
     return mStream->get_sample_rate(mStream);
 }
@@ -201,6 +207,96 @@
     return Void();
 }
 
+#else  // MAJOR_VERSION <= 6
+
+Return<void> Stream::getSupportedProfiles(getSupportedProfiles_cb _hidl_cb) {
+    String8 halListValue;
+    Result result = getParam(AudioParameter::keyStreamSupportedFormats, &halListValue);
+    hidl_vec<AudioProfile> profiles;
+    if (result != Result::OK) {
+        _hidl_cb(result, profiles);
+        return Void();
+    }
+    // Ensure that the separator is one character, despite that it's defined as a C string.
+    static_assert(sizeof(AUDIO_PARAMETER_VALUE_LIST_SEPARATOR) == 2);
+    std::vector<std::string> halFormats =
+            util::splitString(halListValue.string(), AUDIO_PARAMETER_VALUE_LIST_SEPARATOR[0]);
+    hidl_vec<AudioFormat> formats;
+    (void)HidlUtils::audioFormatsFromHal(halFormats, &formats);
+    std::vector<AudioProfile> tempProfiles;
+    for (const auto& format : formats) {
+        audio_format_t halFormat;
+        if (status_t status = HidlUtils::audioFormatToHal(format, &halFormat); status != NO_ERROR) {
+            continue;
+        }
+        AudioParameter context;
+        context.addInt(String8(AUDIO_PARAMETER_STREAM_FORMAT), int(halFormat));
+        // Query supported sample rates for the format.
+        result = getParam(AudioParameter::keyStreamSupportedSamplingRates, &halListValue, context);
+        if (result != Result::OK) break;
+        std::vector<std::string> halSampleRates =
+                util::splitString(halListValue.string(), AUDIO_PARAMETER_VALUE_LIST_SEPARATOR[0]);
+        hidl_vec<uint32_t> sampleRates;
+        sampleRates.resize(halSampleRates.size());
+        for (size_t i = 0; i < sampleRates.size(); ++i) {
+            sampleRates[i] = std::stoi(halSampleRates[i]);
+        }
+        // Query supported channel masks for the format.
+        result = getParam(AudioParameter::keyStreamSupportedChannels, &halListValue, context);
+        if (result != Result::OK) break;
+        std::vector<std::string> halChannelMasks =
+                util::splitString(halListValue.string(), AUDIO_PARAMETER_VALUE_LIST_SEPARATOR[0]);
+        hidl_vec<AudioChannelMask> channelMasks;
+        (void)HidlUtils::audioChannelMasksFromHal(halChannelMasks, &channelMasks);
+        // Create a profile.
+        if (channelMasks.size() != 0 && sampleRates.size() != 0) {
+            tempProfiles.push_back({.format = format,
+                                    .sampleRates = std::move(sampleRates),
+                                    .channelMasks = std::move(channelMasks)});
+        }
+    }
+    // Legacy get_parameter does not return a status_t, thus can not advertise of failure.
+    // Note that the method must not return an empty list if this capability is supported.
+    if (!tempProfiles.empty()) {
+        profiles = tempProfiles;
+    } else {
+        result = Result::NOT_SUPPORTED;
+    }
+    _hidl_cb(result, profiles);
+    return Void();
+}
+
+Return<void> Stream::getAudioProperties(getAudioProperties_cb _hidl_cb) {
+    audio_config_base_t halConfigBase = {mStream->get_sample_rate(mStream),
+                                         mStream->get_channels(mStream),
+                                         mStream->get_format(mStream)};
+    AudioConfigBase configBase = {};
+    status_t status = HidlUtils::audioConfigBaseFromHal(halConfigBase, mIsInput, &configBase);
+    _hidl_cb(Stream::analyzeStatus("get_audio_properties", status), configBase);
+    return Void();
+}
+
+Return<Result> Stream::setAudioProperties(const AudioConfigBase& config) {
+    audio_config_base_t halConfigBase = {};
+    status_t status = HidlUtils::audioConfigBaseToHal(config, &halConfigBase);
+    if (status != NO_ERROR) {
+        return Stream::analyzeStatus("set_audio_properties", status);
+    }
+    if (Result result = setParam(AudioParameter::keySamplingRate,
+                                 static_cast<int>(halConfigBase.sample_rate));
+        result != Result::OK) {
+        return result;
+    }
+    if (Result result =
+                setParam(AudioParameter::keyChannels, static_cast<int>(halConfigBase.channel_mask));
+        result != Result::OK) {
+        return result;
+    }
+    return setParam(AudioParameter::keyFormat, static_cast<int>(halConfigBase.format));
+}
+
+#endif  // MAJOR_VERSION <= 6
+
 Return<Result> Stream::addEffect(uint64_t effectId) {
     effect_handle_t halEffect = EffectMap::getInstance().get(effectId);
     if (halEffect != NULL) {
@@ -257,12 +353,14 @@
 }
 #elif MAJOR_VERSION >= 4
 Return<void> Stream::getDevices(getDevices_cb _hidl_cb) {
-    int device = 0;
-    Result retval = getParam(AudioParameter::keyRouting, &device);
+    int halDevice = 0;
+    Result retval = getParam(AudioParameter::keyRouting, &halDevice);
     hidl_vec<DeviceAddress> devices;
     if (retval == Result::OK) {
         devices.resize(1);
-        devices[0].device = static_cast<AudioDevice>(device);
+        retval = Stream::analyzeStatus("get_devices",
+                                       deviceAddressFromHal(static_cast<audio_devices_t>(halDevice),
+                                                            nullptr, &devices[0]));
     }
     _hidl_cb(retval, devices);
     return Void();
@@ -273,14 +371,13 @@
     if (devices.size() > 1) {
         return Result::NOT_SUPPORTED;
     }
-    DeviceAddress address;
+    DeviceAddress address{};
     if (devices.size() == 1) {
         address = devices[0];
-    } else {
-        address.device = AudioDevice::NONE;
     }
     return setParam(AudioParameter::keyRouting, address);
 }
+
 Return<void> Stream::getParameters(const hidl_vec<ParameterValue>& context,
                                    const hidl_vec<hidl_string>& keys, getParameters_cb _hidl_cb) {
     getParametersImpl(context, keys, _hidl_cb);
diff --git a/audio/core/all-versions/default/StreamIn.cpp b/audio/core/all-versions/default/StreamIn.cpp
index f1152ca..ead7204 100644
--- a/audio/core/all-versions/default/StreamIn.cpp
+++ b/audio/core/all-versions/default/StreamIn.cpp
@@ -24,11 +24,12 @@
 //#define LOG_NDEBUG 0
 #define ATRACE_TAG ATRACE_TAG_AUDIO
 
+#include <HidlUtils.h>
 #include <android/log.h>
 #include <hardware/audio.h>
 #include <utils/Trace.h>
-#include <memory>
 #include <cmath>
+#include <memory>
 
 namespace android {
 namespace hardware {
@@ -36,6 +37,8 @@
 namespace CPP_VERSION {
 namespace implementation {
 
+using ::android::hardware::audio::common::CPP_VERSION::implementation::HidlUtils;
+
 namespace {
 
 class ReadThread : public Thread {
@@ -141,7 +144,7 @@
 StreamIn::StreamIn(const sp<Device>& device, audio_stream_in_t* stream)
     : mDevice(device),
       mStream(stream),
-      mStreamCommon(new Stream(&stream->common)),
+      mStreamCommon(new Stream(true /*isInput*/, &stream->common)),
       mStreamMmap(new StreamMmap<audio_stream_in_t>(stream)),
       mEfGroup(nullptr),
       mStopReadThread(false) {}
@@ -177,6 +180,7 @@
     return mStreamCommon->getBufferSize();
 }
 
+#if MAJOR_VERSION <= 6
 Return<uint32_t> StreamIn::getSampleRate() {
     return mStreamCommon->getSampleRate();
 }
@@ -223,6 +227,18 @@
     return mStreamCommon->setFormat(format);
 }
 
+#else
+
+Return<void> StreamIn::getSupportedProfiles(getSupportedProfiles_cb _hidl_cb) {
+    return mStreamCommon->getSupportedProfiles(_hidl_cb);
+}
+
+Return<Result> StreamIn::setAudioProperties(const AudioConfigBase& config) {
+    return mStreamCommon->setAudioProperties(config);
+}
+
+#endif  // MAJOR_VERSION <= 6
+
 Return<void> StreamIn::getAudioProperties(getAudioProperties_cb _hidl_cb) {
     return mStreamCommon->getAudioProperties(_hidl_cb);
 }
@@ -321,9 +337,11 @@
 Return<void> StreamIn::getAudioSource(getAudioSource_cb _hidl_cb) {
     int halSource;
     Result retval = mStreamCommon->getParam(AudioParameter::keyInputSource, &halSource);
-    AudioSource source(AudioSource::DEFAULT);
+    AudioSource source = {};
     if (retval == Result::OK) {
-        source = AudioSource(halSource);
+        retval = Stream::analyzeStatus(
+                "get_audio_source",
+                HidlUtils::audioSourceFromHal(static_cast<audio_source_t>(halSource), &source));
     }
     _hidl_cb(retval, source);
     return Void();
@@ -340,7 +358,11 @@
 Return<void> StreamIn::prepareForReading(uint32_t frameSize, uint32_t framesCount,
                                          prepareForReading_cb _hidl_cb) {
     status_t status;
+#if MAJOR_VERSION <= 6
     ThreadInfo threadInfo = {0, 0};
+#else
+    int32_t threadInfo = 0;
+#endif
 
     // Wrap the _hidl_cb to return an error
     auto sendError = [&threadInfo, &_hidl_cb](Result result) {
@@ -410,8 +432,12 @@
     mStatusMQ = std::move(tempStatusMQ);
     mReadThread = tempReadThread.release();
     mEfGroup = tempElfGroup.release();
+#if MAJOR_VERSION <= 6
     threadInfo.pid = getpid();
     threadInfo.tid = mReadThread->getTid();
+#else
+    threadInfo = mReadThread->getTid();
+#endif
     _hidl_cb(Result::OK, *mCommandMQ->getDesc(), *mDataMQ->getDesc(), *mStatusMQ->getDesc(),
              threadInfo);
     return Void();
@@ -459,16 +485,13 @@
     std::vector<record_track_metadata> halTracks;
     halTracks.reserve(sinkMetadata.tracks.size());
     for (auto& metadata : sinkMetadata.tracks) {
-        record_track_metadata halTrackMetadata = {
-            .source = static_cast<audio_source_t>(metadata.source), .gain = metadata.gain};
+        record_track_metadata halTrackMetadata = {.gain = metadata.gain};
+        (void)HidlUtils::audioSourceToHal(metadata.source, &halTrackMetadata.source);
 #if MAJOR_VERSION >= 5
         if (metadata.destination.getDiscriminator() ==
             RecordTrackMetadata::Destination::hidl_discriminator::device) {
-            halTrackMetadata.dest_device =
-                static_cast<audio_devices_t>(metadata.destination.device().device);
-            strncpy(halTrackMetadata.dest_device_address,
-                    deviceAddressToHal(metadata.destination.device()).c_str(),
-                    AUDIO_DEVICE_MAX_ADDRESS_LEN);
+            (void)deviceAddressToHal(metadata.destination.device(), &halTrackMetadata.dest_device,
+                                     halTrackMetadata.dest_device_address);
         }
 #endif
         halTracks.push_back(halTrackMetadata);
diff --git a/audio/core/all-versions/default/StreamOut.cpp b/audio/core/all-versions/default/StreamOut.cpp
index 007eb45..5633cbb 100644
--- a/audio/core/all-versions/default/StreamOut.cpp
+++ b/audio/core/all-versions/default/StreamOut.cpp
@@ -26,6 +26,7 @@
 
 #include <memory>
 
+#include <HidlUtils.h>
 #include <android/log.h>
 #include <hardware/audio.h>
 #include <utils/Trace.h>
@@ -36,6 +37,8 @@
 namespace CPP_VERSION {
 namespace implementation {
 
+using ::android::hardware::audio::common::CPP_VERSION::implementation::HidlUtils;
+
 namespace {
 
 class WriteThread : public Thread {
@@ -142,7 +145,7 @@
 StreamOut::StreamOut(const sp<Device>& device, audio_stream_out_t* stream)
     : mDevice(device),
       mStream(stream),
-      mStreamCommon(new Stream(&stream->common)),
+      mStreamCommon(new Stream(false /*isInput*/, &stream->common)),
       mStreamMmap(new StreamMmap<audio_stream_out_t>(stream)),
       mEfGroup(nullptr),
       mStopWriteThread(false) {}
@@ -182,6 +185,7 @@
     return mStreamCommon->getBufferSize();
 }
 
+#if MAJOR_VERSION <= 6
 Return<uint32_t> StreamOut::getSampleRate() {
     return mStreamCommon->getSampleRate();
 }
@@ -228,6 +232,18 @@
     return mStreamCommon->setFormat(format);
 }
 
+#else
+
+Return<void> StreamOut::getSupportedProfiles(getSupportedProfiles_cb _hidl_cb) {
+    return mStreamCommon->getSupportedProfiles(_hidl_cb);
+}
+
+Return<Result> StreamOut::setAudioProperties(const AudioConfigBase& config) {
+    return mStreamCommon->setAudioProperties(config);
+}
+
+#endif  // MAJOR_VERSION <= 6
+
 Return<void> StreamOut::getAudioProperties(getAudioProperties_cb _hidl_cb) {
     return mStreamCommon->getAudioProperties(_hidl_cb);
 }
@@ -327,7 +343,11 @@
 Return<void> StreamOut::prepareForWriting(uint32_t frameSize, uint32_t framesCount,
                                           prepareForWriting_cb _hidl_cb) {
     status_t status;
+#if MAJOR_VERSION <= 6
     ThreadInfo threadInfo = {0, 0};
+#else
+    int32_t threadInfo = 0;
+#endif
 
     // Wrap the _hidl_cb to return an error
     auto sendError = [&threadInfo, &_hidl_cb](Result result) {
@@ -396,8 +416,12 @@
     mStatusMQ = std::move(tempStatusMQ);
     mWriteThread = tempWriteThread.release();
     mEfGroup = tempElfGroup.release();
+#if MAJOR_VERSION <= 6
     threadInfo.pid = getpid();
     threadInfo.tid = mWriteThread->getTid();
+#else
+    threadInfo = mWriteThread->getTid();
+#endif
     _hidl_cb(Result::OK, *mCommandMQ->getDesc(), *mDataMQ->getDesc(), *mStatusMQ->getDesc(),
              threadInfo);
     return Void();
@@ -565,14 +589,14 @@
     if (mStream->update_source_metadata == nullptr) {
         return Void();  // not supported by the HAL
     }
-    std::vector<playback_track_metadata> halTracks;
+    std::vector<playback_track_metadata_t> halTracks;
     halTracks.reserve(sourceMetadata.tracks.size());
     for (auto& metadata : sourceMetadata.tracks) {
-        halTracks.push_back({
-            .usage = static_cast<audio_usage_t>(metadata.usage),
-            .content_type = static_cast<audio_content_type_t>(metadata.contentType),
-            .gain = metadata.gain,
-        });
+        playback_track_metadata_t halTrackMetadata = {.gain = metadata.gain};
+        (void)HidlUtils::audioUsageToHal(metadata.usage, &halTrackMetadata.usage);
+        (void)HidlUtils::audioContentTypeToHal(metadata.contentType,
+                                               &halTrackMetadata.content_type);
+        halTracks.push_back(std::move(halTrackMetadata));
     }
     const source_metadata_t halMetadata = {
         .track_count = halTracks.size(),
diff --git a/audio/core/all-versions/default/include/core/default/Conversions.h b/audio/core/all-versions/default/include/core/default/Conversions.h
index cb7914f..2372771 100644
--- a/audio/core/all-versions/default/include/core/default/Conversions.h
+++ b/audio/core/all-versions/default/include/core/default/Conversions.h
@@ -23,22 +23,54 @@
 
 #include <system/audio.h>
 
+#include <VersionUtils.h>
+
 namespace android {
 namespace hardware {
 namespace audio {
 namespace CPP_VERSION {
 namespace implementation {
 
+using ::android::hardware::hidl_vec;
 using namespace ::android::hardware::audio::common::CPP_VERSION;
 using namespace ::android::hardware::audio::CPP_VERSION;
 
+#if MAJOR_VERSION <= 6
+// Temporary version for compatibility with forks of the default implementation.
+// Will be removed, do not use!
 std::string deviceAddressToHal(const DeviceAddress& address);
+#endif
+
+status_t deviceAddressToHal(const DeviceAddress& device, audio_devices_t* halDeviceType,
+                            char* halDeviceAddress);
+status_t deviceAddressFromHal(audio_devices_t halDeviceType, const char* halDeviceAddress,
+                              DeviceAddress* device);
 
 #if MAJOR_VERSION >= 4
 bool halToMicrophoneCharacteristics(MicrophoneInfo* pDst,
                                     const struct audio_microphone_characteristic_t& src);
 #endif
 
+#if MAJOR_VERSION <= 6
+using AudioInputFlags =
+        ::android::hardware::audio::common::CPP_VERSION::implementation::AudioInputFlagBitfield;
+using AudioOutputFlags =
+        ::android::hardware::audio::common::CPP_VERSION::implementation::AudioOutputFlagBitfield;
+
+inline bool audioInputFlagsToHal(AudioInputFlags flags, audio_input_flags_t* halFlags) {
+    *halFlags = static_cast<audio_input_flags_t>(flags);
+    return true;
+}
+
+inline bool audioOutputFlagsToHal(AudioOutputFlags flags, audio_output_flags_t* halFlags) {
+    *halFlags = static_cast<audio_output_flags_t>(flags);
+    return true;
+}
+#else
+bool audioInputFlagsToHal(const hidl_vec<AudioInOutFlag>& flags, audio_input_flags_t* halFlags);
+bool audioOutputFlagsToHal(const hidl_vec<AudioInOutFlag>& flags, audio_output_flags_t* halFlags);
+#endif
+
 }  // namespace implementation
 }  // namespace CPP_VERSION
 }  // namespace audio
diff --git a/audio/core/all-versions/default/include/core/default/Device.h b/audio/core/all-versions/default/include/core/default/Device.h
index 907acd7..461c253 100644
--- a/audio/core/all-versions/default/include/core/default/Device.h
+++ b/audio/core/all-versions/default/include/core/default/Device.h
@@ -44,8 +44,13 @@
 using ::android::hardware::Return;
 using ::android::hardware::Void;
 #if MAJOR_VERSION <= 6
-using ::android::hardware::audio::common::CPP_VERSION::implementation::AudioInputFlagBitfield;
-using ::android::hardware::audio::common::CPP_VERSION::implementation::AudioOutputFlagBitfield;
+using AudioInputFlags =
+        ::android::hardware::audio::common::CPP_VERSION::implementation::AudioInputFlagBitfield;
+using AudioOutputFlags =
+        ::android::hardware::audio::common::CPP_VERSION::implementation::AudioOutputFlagBitfield;
+#else
+using AudioInputFlags = hidl_vec<::android::hardware::audio::CPP_VERSION::AudioInOutFlag>;
+using AudioOutputFlags = hidl_vec<::android::hardware::audio::CPP_VERSION::AudioInOutFlag>;
 #endif
 using namespace ::android::hardware::audio::common::CPP_VERSION;
 using namespace ::android::hardware::audio::CPP_VERSION;
@@ -67,28 +72,36 @@
     std::tuple<Result, sp<IStreamOut>> openOutputStreamImpl(int32_t ioHandle,
                                                             const DeviceAddress& device,
                                                             const AudioConfig& config,
-                                                            AudioOutputFlagBitfield flags,
+                                                            const AudioOutputFlags& flags,
                                                             AudioConfig* suggestedConfig);
     std::tuple<Result, sp<IStreamIn>> openInputStreamImpl(
-        int32_t ioHandle, const DeviceAddress& device, const AudioConfig& config,
-        AudioInputFlagBitfield flags, AudioSource source, AudioConfig* suggestedConfig);
-#if MAJOR_VERSION == 2
+            int32_t ioHandle, const DeviceAddress& device, const AudioConfig& config,
+            const AudioInputFlags& flags, AudioSource source, AudioConfig* suggestedConfig);
+
     Return<void> openOutputStream(int32_t ioHandle, const DeviceAddress& device,
-                                  const AudioConfig& config, AudioOutputFlagBitfield flags,
-                                  openOutputStream_cb _hidl_cb) override;
-    Return<void> openInputStream(int32_t ioHandle, const DeviceAddress& device,
-                                 const AudioConfig& config, AudioInputFlagBitfield flags,
-                                 AudioSource source, openInputStream_cb _hidl_cb) override;
-#elif MAJOR_VERSION >= 4
-    Return<void> openOutputStream(int32_t ioHandle, const DeviceAddress& device,
-                                  const AudioConfig& config, AudioOutputFlagBitfield flags,
-                                  const SourceMetadata& sourceMetadata,
-                                  openOutputStream_cb _hidl_cb) override;
-    Return<void> openInputStream(int32_t ioHandle, const DeviceAddress& device,
-                                 const AudioConfig& config, AudioInputFlagBitfield flags,
-                                 const SinkMetadata& sinkMetadata,
-                                 openInputStream_cb _hidl_cb) override;
+                                  const AudioConfig& config,
+#if MAJOR_VERSION <= 6
+                                  AudioOutputFlags flags,
+#else
+                                  const AudioOutputFlags& flags,
 #endif
+#if MAJOR_VERSION >= 4
+                                  const SourceMetadata& sourceMetadata,
+#endif
+                                  openOutputStream_cb _hidl_cb) override;
+    Return<void> openInputStream(int32_t ioHandle, const DeviceAddress& device,
+                                 const AudioConfig& config,
+#if MAJOR_VERSION <= 6
+                                 AudioInputFlags flags,
+#else
+                                 const AudioInputFlags& flags,
+#endif
+#if MAJOR_VERSION == 2
+                                 AudioSource source,
+#elif MAJOR_VERSION >= 4
+                                 const SinkMetadata& sinkMetadata,
+#endif
+                                 openInputStream_cb _hidl_cb) override;
 
     Return<bool> supportsAudioPatches() override;
     Return<void> createAudioPatch(const hidl_vec<AudioPortConfig>& sources,
diff --git a/audio/core/all-versions/default/include/core/default/PrimaryDevice.h b/audio/core/all-versions/default/include/core/default/PrimaryDevice.h
index ccdb7b2..5f65acf 100644
--- a/audio/core/all-versions/default/include/core/default/PrimaryDevice.h
+++ b/audio/core/all-versions/default/include/core/default/PrimaryDevice.h
@@ -54,21 +54,29 @@
                                     getInputBufferSize_cb _hidl_cb) override;
 
     Return<void> openOutputStream(int32_t ioHandle, const DeviceAddress& device,
-                                  const AudioConfig& config, AudioOutputFlagBitfield flags,
+                                  const AudioConfig& config,
+#if MAJOR_VERSION <= 6
+                                  AudioOutputFlags flags,
+#else
+                                  const AudioOutputFlags& flags,
+#endif
 #if MAJOR_VERSION >= 4
                                   const SourceMetadata& sourceMetadata,
 #endif
                                   openOutputStream_cb _hidl_cb) override;
-
     Return<void> openInputStream(int32_t ioHandle, const DeviceAddress& device,
-                                 const AudioConfig& config, AudioInputFlagBitfield flags,
-                                 AudioSource source, openInputStream_cb _hidl_cb);
-#if MAJOR_VERSION >= 4
-    Return<void> openInputStream(int32_t ioHandle, const DeviceAddress& device,
-                                 const AudioConfig& config, AudioInputFlagBitfield flags,
-                                 const SinkMetadata& sinkMetadata,
-                                 openInputStream_cb _hidl_cb) override;
+                                 const AudioConfig& config,
+#if MAJOR_VERSION <= 6
+                                 AudioInputFlags flags,
+#else
+                                 const AudioInputFlags& flags,
 #endif
+#if MAJOR_VERSION == 2
+                                 AudioSource source,
+#elif MAJOR_VERSION >= 4
+                                 const SinkMetadata& sinkMetadata,
+#endif
+                                 openInputStream_cb _hidl_cb) override;
 
     Return<bool> supportsAudioPatches() override;
     Return<void> createAudioPatch(const hidl_vec<AudioPortConfig>& sources,
diff --git a/audio/core/all-versions/default/include/core/default/Stream.h b/audio/core/all-versions/default/include/core/default/Stream.h
index ce0003b..0865992 100644
--- a/audio/core/all-versions/default/include/core/default/Stream.h
+++ b/audio/core/all-versions/default/include/core/default/Stream.h
@@ -41,12 +41,14 @@
 using ::android::hardware::hidl_vec;
 using ::android::hardware::Return;
 using ::android::hardware::Void;
+#if MAJOR_VERSION <= 6
 using ::android::hardware::audio::common::CPP_VERSION::implementation::AudioChannelBitfield;
+#endif
 using namespace ::android::hardware::audio::common::CPP_VERSION;
 using namespace ::android::hardware::audio::CPP_VERSION;
 
 struct Stream : public IStream, public ParametersUtil {
-    explicit Stream(audio_stream_t* stream);
+    Stream(bool isInput, audio_stream_t* stream);
 
     /** 1GiB is the maximum buffer size the HAL client is allowed to request.
      * This value has been chosen to be under SIZE_MAX and still big enough
@@ -59,6 +61,7 @@
     Return<uint64_t> getFrameSize() override;
     Return<uint64_t> getFrameCount() override;
     Return<uint64_t> getBufferSize() override;
+#if MAJOR_VERSION <= 6
     Return<uint32_t> getSampleRate() override;
 #if MAJOR_VERSION == 2
     Return<void> getSupportedSampleRates(getSupportedSampleRates_cb _hidl_cb) override;
@@ -72,6 +75,10 @@
     Return<AudioFormat> getFormat() override;
     Return<void> getSupportedFormats(getSupportedFormats_cb _hidl_cb) override;
     Return<Result> setFormat(AudioFormat format) override;
+#else
+    Return<void> getSupportedProfiles(getSupportedProfiles_cb _hidl_cb) override;
+    Return<Result> setAudioProperties(const AudioConfigBase& config) override;
+#endif  // MAJOR_VERSION <= 6
     Return<void> getAudioProperties(getAudioProperties_cb _hidl_cb) override;
     Return<Result> addEffect(uint64_t effectId) override;
     Return<Result> removeEffect(uint64_t effectId) override;
@@ -110,13 +117,14 @@
                                 const std::vector<int>& ignoreErrors);
 
    private:
-    audio_stream_t* mStream;
+     const bool mIsInput;
+     audio_stream_t* mStream;
 
-    virtual ~Stream();
+     virtual ~Stream();
 
-    // Methods from ParametersUtil.
-    char* halGetParameters(const char* keys) override;
-    int halSetParameters(const char* keysAndValues) override;
+     // Methods from ParametersUtil.
+     char* halGetParameters(const char* keys) override;
+     int halSetParameters(const char* keysAndValues) override;
 };
 
 template <typename T>
diff --git a/audio/core/all-versions/default/include/core/default/StreamIn.h b/audio/core/all-versions/default/include/core/default/StreamIn.h
index 24f9944..b861c6c 100644
--- a/audio/core/all-versions/default/include/core/default/StreamIn.h
+++ b/audio/core/all-versions/default/include/core/default/StreamIn.h
@@ -56,6 +56,7 @@
     Return<uint64_t> getFrameSize() override;
     Return<uint64_t> getFrameCount() override;
     Return<uint64_t> getBufferSize() override;
+#if MAJOR_VERSION <= 6
     Return<uint32_t> getSampleRate() override;
 #if MAJOR_VERSION == 2
     Return<void> getSupportedSampleRates(getSupportedSampleRates_cb _hidl_cb) override;
@@ -69,6 +70,10 @@
     Return<AudioFormat> getFormat() override;
     Return<void> getSupportedFormats(getSupportedFormats_cb _hidl_cb) override;
     Return<Result> setFormat(AudioFormat format) override;
+#else
+    Return<void> getSupportedProfiles(getSupportedProfiles_cb _hidl_cb) override;
+    Return<Result> setAudioProperties(const AudioConfigBase& config) override;
+#endif  // MAJOR_VERSION <= 6
     Return<void> getAudioProperties(getAudioProperties_cb _hidl_cb) override;
     Return<Result> addEffect(uint64_t effectId) override;
     Return<Result> removeEffect(uint64_t effectId) override;
diff --git a/audio/core/all-versions/default/include/core/default/StreamOut.h b/audio/core/all-versions/default/include/core/default/StreamOut.h
index e647da9..9f64e3e 100644
--- a/audio/core/all-versions/default/include/core/default/StreamOut.h
+++ b/audio/core/all-versions/default/include/core/default/StreamOut.h
@@ -56,6 +56,7 @@
     Return<uint64_t> getFrameSize() override;
     Return<uint64_t> getFrameCount() override;
     Return<uint64_t> getBufferSize() override;
+#if MAJOR_VERSION <= 6
     Return<uint32_t> getSampleRate() override;
 #if MAJOR_VERSION == 2
     Return<void> getSupportedSampleRates(getSupportedSampleRates_cb _hidl_cb) override;
@@ -69,6 +70,10 @@
     Return<AudioFormat> getFormat() override;
     Return<void> getSupportedFormats(getSupportedFormats_cb _hidl_cb) override;
     Return<Result> setFormat(AudioFormat format) override;
+#else
+    Return<void> getSupportedProfiles(getSupportedProfiles_cb _hidl_cb) override;
+    Return<Result> setAudioProperties(const AudioConfigBase& config) override;
+#endif  // MAJOR_VERSION <= 6
     Return<void> getAudioProperties(getAudioProperties_cb _hidl_cb) override;
     Return<Result> addEffect(uint64_t effectId) override;
     Return<Result> removeEffect(uint64_t effectId) override;
diff --git a/audio/core/all-versions/default/include/core/default/Util.h b/audio/core/all-versions/default/include/core/default/Util.h
index 78ae03e..3d629cd 100644
--- a/audio/core/all-versions/default/include/core/default/Util.h
+++ b/audio/core/all-versions/default/include/core/default/Util.h
@@ -20,6 +20,8 @@
 #include PATH(android/hardware/audio/FILE_VERSION/types.h)
 
 #include <algorithm>
+#include <sstream>
+#include <string>
 #include <vector>
 
 #include <system/audio.h>
@@ -70,6 +72,16 @@
     return analyzeStatus(status);
 }
 
+static inline std::vector<std::string> splitString(const std::string& s, char separator) {
+    std::istringstream iss(s);
+    std::string t;
+    std::vector<std::string> result;
+    while (std::getline(iss, t, separator)) {
+        result.push_back(std::move(t));
+    }
+    return result;
+}
+
 }  // namespace util
 }  // namespace implementation
 }  // namespace CPP_VERSION
diff --git a/audio/core/all-versions/vts/functional/AudioPrimaryHidlHalTest.h b/audio/core/all-versions/vts/functional/AudioPrimaryHidlHalTest.h
index 1ead47c..05c9bf7 100644
--- a/audio/core/all-versions/vts/functional/AudioPrimaryHidlHalTest.h
+++ b/audio/core/all-versions/vts/functional/AudioPrimaryHidlHalTest.h
@@ -1179,9 +1179,11 @@
     EXPECT_EQ(expectedConfig.channelMask, mask);
     EXPECT_EQ(expectedConfig.format, format);
 #elif MAJOR_VERSION >= 7
+    Result res;
     AudioConfigBase actualConfig{};
-    auto ret = stream->getAudioProperties(returnIn(actualConfig));
+    auto ret = stream->getAudioProperties(returnIn(res, actualConfig));
     EXPECT_TRUE(ret.isOk());
+    EXPECT_EQ(Result::OK, res);
     EXPECT_EQ(expectedConfig.base.sampleRateHz, actualConfig.sampleRateHz);
     EXPECT_EQ(expectedConfig.base.channelMask, actualConfig.channelMask);
     EXPECT_EQ(expectedConfig.base.format, actualConfig.format);
diff --git a/audio/effect/7.0/IVirtualizerEffect.hal b/audio/effect/7.0/IVirtualizerEffect.hal
index 141b4e6..5d11435 100644
--- a/audio/effect/7.0/IVirtualizerEffect.hal
+++ b/audio/effect/7.0/IVirtualizerEffect.hal
@@ -46,23 +46,38 @@
      */
     getStrength() generates (Result retval, uint16_t strength);
 
-    struct SpeakerAngle {
+    struct SpeakerAngles {
         /** Speaker channel mask */
-        vec<AudioChannelMask> mask;
-        // all angles are expressed in degrees and
-        // are relative to the listener.
-        int16_t azimuth; // 0 is the direction the listener faces
-                         // 180 is behind the listener
-                         // -90 is to their left
-        int16_t elevation; // 0 is the horizontal plane
-                           // +90 is above the listener, -90 is below
+        AudioChannelMask mask;
+        /**
+         * Horizontal speaker position angles for each channel ordered from LSb
+         * to MSb in the channel mask. The number of values is the number of
+         * channels in the channel mask.
+         *
+         * All angles are expressed in degrees and are relative to the listener.
+         *  - 0 is the direction the listener faces;
+         *  - 180 is behind the listener;
+         *  - -90 is to their left.
+         */
+        vec<int16_t> azimuth;
+        /**
+         * Vertical speaker position angles for each channel ordered from LSb
+         * to MSb in the channel mask. The number of values is the number of
+         * channels in the channel mask.
+         *
+         * All angles are expressed in degrees and are relative to the listener.
+         *  - 0 is the horizontal plane of the listener;
+         *  - +90 is above the listener;
+         *  - -90 is below the listener.
+         */
+        vec<int16_t> elevation;
     };
     /**
      * Retrieves virtual speaker angles for the given channel mask on the
      * specified device.
      */
-    getVirtualSpeakerAngles(vec<AudioChannelMask> mask, DeviceAddress device)
-            generates (Result retval, vec<SpeakerAngle> speakerAngles);
+    getVirtualSpeakerAngles(AudioChannelMask mask, DeviceAddress device)
+            generates (Result retval, SpeakerAngles speakerAngles);
 
     /**
      * Forces the virtualizer effect for the given output device.
diff --git a/audio/effect/7.0/types.hal b/audio/effect/7.0/types.hal
index b0a0709..c4cb213 100644
--- a/audio/effect/7.0/types.hal
+++ b/audio/effect/7.0/types.hal
@@ -271,9 +271,7 @@
  */
 struct EffectBufferConfig {
     AudioBuffer buffer;
-    uint32_t samplingRateHz;
-    AudioChannelMask channels;
-    AudioFormat format;
+    AudioConfigBase base;
     EffectBufferAccess accessMode;
     bitfield<EffectConfigParameters> mask;
 };
@@ -292,9 +290,9 @@
 
 struct EffectAuxChannelsConfig {
     /** Channel mask for main channels. */
-    vec<AudioChannelMask> mainChannels;
+    AudioChannelMask mainChannels;
     /** Channel mask for auxiliary channels. */
-    vec<AudioChannelMask> auxChannels;
+    AudioChannelMask auxChannels;
 };
 
 struct EffectOffloadParameter {
diff --git a/audio/effect/all-versions/default/AcousticEchoCancelerEffect.cpp b/audio/effect/all-versions/default/AcousticEchoCancelerEffect.cpp
index 137ea24..c1a8b55 100644
--- a/audio/effect/all-versions/default/AcousticEchoCancelerEffect.cpp
+++ b/audio/effect/all-versions/default/AcousticEchoCancelerEffect.cpp
@@ -31,9 +31,7 @@
 namespace implementation {
 
 AcousticEchoCancelerEffect::AcousticEchoCancelerEffect(effect_handle_t handle)
-    : mEffect(new Effect(handle)) {}
-
-AcousticEchoCancelerEffect::~AcousticEchoCancelerEffect() {}
+    : mEffect(new Effect(true /*isInput*/, handle)) {}
 
 // Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffect follow.
 Return<Result> AcousticEchoCancelerEffect::init() {
@@ -58,10 +56,32 @@
     return mEffect->disable();
 }
 
+#if MAJOR_VERSION <= 6
+Return<Result> AcousticEchoCancelerEffect::setAudioSource(AudioSource source) {
+    return mEffect->setAudioSource(source);
+}
+
 Return<Result> AcousticEchoCancelerEffect::setDevice(AudioDeviceBitfield device) {
     return mEffect->setDevice(device);
 }
 
+Return<Result> AcousticEchoCancelerEffect::setInputDevice(AudioDeviceBitfield device) {
+    return mEffect->setInputDevice(device);
+}
+#else
+Return<Result> AcousticEchoCancelerEffect::setAudioSource(const AudioSource& source) {
+    return mEffect->setAudioSource(source);
+}
+
+Return<Result> AcousticEchoCancelerEffect::setDevice(const DeviceAddress& device) {
+    return mEffect->setDevice(device);
+}
+
+Return<Result> AcousticEchoCancelerEffect::setInputDevice(const DeviceAddress& device) {
+    return mEffect->setInputDevice(device);
+}
+#endif
+
 Return<void> AcousticEchoCancelerEffect::setAndGetVolume(const hidl_vec<uint32_t>& volumes,
                                                          setAndGetVolume_cb _hidl_cb) {
     return mEffect->setAndGetVolume(volumes, _hidl_cb);
@@ -82,10 +102,6 @@
     return mEffect->setConfigReverse(config, inputBufferProvider, outputBufferProvider);
 }
 
-Return<Result> AcousticEchoCancelerEffect::setInputDevice(AudioDeviceBitfield device) {
-    return mEffect->setInputDevice(device);
-}
-
 Return<void> AcousticEchoCancelerEffect::getConfig(getConfig_cb _hidl_cb) {
     return mEffect->getConfig(_hidl_cb);
 }
@@ -108,10 +124,6 @@
     return mEffect->setAuxChannelsConfig(config);
 }
 
-Return<Result> AcousticEchoCancelerEffect::setAudioSource(AudioSource source) {
-    return mEffect->setAudioSource(source);
-}
-
 Return<Result> AcousticEchoCancelerEffect::offload(const EffectOffloadParameter& param) {
     return mEffect->offload(param);
 }
diff --git a/audio/effect/all-versions/default/AcousticEchoCancelerEffect.h b/audio/effect/all-versions/default/AcousticEchoCancelerEffect.h
index 971f64d..d7a84f2 100644
--- a/audio/effect/all-versions/default/AcousticEchoCancelerEffect.h
+++ b/audio/effect/all-versions/default/AcousticEchoCancelerEffect.h
@@ -53,7 +53,15 @@
     Return<Result> reset() override;
     Return<Result> enable() override;
     Return<Result> disable() override;
+#if MAJOR_VERSION <= 6
+    Return<Result> setAudioSource(AudioSource source) override;
     Return<Result> setDevice(AudioDeviceBitfield device) override;
+    Return<Result> setInputDevice(AudioDeviceBitfield device) override;
+#else
+    Return<Result> setAudioSource(const AudioSource& source) override;
+    Return<Result> setDevice(const DeviceAddress& device) override;
+    Return<Result> setInputDevice(const DeviceAddress& device) override;
+#endif
     Return<void> setAndGetVolume(const hidl_vec<uint32_t>& volumes,
                                  setAndGetVolume_cb _hidl_cb) override;
     Return<Result> volumeChangeNotification(const hidl_vec<uint32_t>& volumes) override;
@@ -61,14 +69,12 @@
     Return<Result> setConfigReverse(
         const EffectConfig& config, const sp<IEffectBufferProviderCallback>& inputBufferProvider,
         const sp<IEffectBufferProviderCallback>& outputBufferProvider) override;
-    Return<Result> setInputDevice(AudioDeviceBitfield device) override;
     Return<void> getConfig(getConfig_cb _hidl_cb) override;
     Return<void> getConfigReverse(getConfigReverse_cb _hidl_cb) override;
     Return<void> getSupportedAuxChannelsConfigs(
         uint32_t maxConfigs, getSupportedAuxChannelsConfigs_cb _hidl_cb) override;
     Return<void> getAuxChannelsConfig(getAuxChannelsConfig_cb _hidl_cb) override;
     Return<Result> setAuxChannelsConfig(const EffectAuxChannelsConfig& config) override;
-    Return<Result> setAudioSource(AudioSource source) override;
     Return<Result> offload(const EffectOffloadParameter& param) override;
     Return<void> getDescriptor(getDescriptor_cb _hidl_cb) override;
     Return<void> prepareForProcessing(prepareForProcessing_cb _hidl_cb) override;
@@ -98,7 +104,7 @@
    private:
     sp<Effect> mEffect;
 
-    virtual ~AcousticEchoCancelerEffect();
+    virtual ~AcousticEchoCancelerEffect() = default;
 };
 
 }  // namespace implementation
diff --git a/audio/effect/all-versions/default/Android.bp b/audio/effect/all-versions/default/Android.bp
index 1c3dc74..a0cd612 100644
--- a/audio/effect/all-versions/default/Android.bp
+++ b/audio/effect/all-versions/default/Android.bp
@@ -105,7 +105,6 @@
 }
 
 cc_library_shared {
-    enabled: false,
     name: "android.hardware.audio.effect@7.0-impl",
     defaults: ["android.hardware.audio.effect-impl_default"],
     shared_libs: [
diff --git a/audio/effect/all-versions/default/AutomaticGainControlEffect.cpp b/audio/effect/all-versions/default/AutomaticGainControlEffect.cpp
index 655a4cd..110b1b6 100644
--- a/audio/effect/all-versions/default/AutomaticGainControlEffect.cpp
+++ b/audio/effect/all-versions/default/AutomaticGainControlEffect.cpp
@@ -30,9 +30,7 @@
 namespace implementation {
 
 AutomaticGainControlEffect::AutomaticGainControlEffect(effect_handle_t handle)
-    : mEffect(new Effect(handle)) {}
-
-AutomaticGainControlEffect::~AutomaticGainControlEffect() {}
+    : mEffect(new Effect(true /*isInput*/, handle)) {}
 
 void AutomaticGainControlEffect::propertiesFromHal(
     const t_agc_settings& halProperties, IAutomaticGainControlEffect::AllProperties* properties) {
@@ -71,10 +69,32 @@
     return mEffect->disable();
 }
 
+#if MAJOR_VERSION <= 6
+Return<Result> AutomaticGainControlEffect::setAudioSource(AudioSource source) {
+    return mEffect->setAudioSource(source);
+}
+
 Return<Result> AutomaticGainControlEffect::setDevice(AudioDeviceBitfield device) {
     return mEffect->setDevice(device);
 }
 
+Return<Result> AutomaticGainControlEffect::setInputDevice(AudioDeviceBitfield device) {
+    return mEffect->setInputDevice(device);
+}
+#else
+Return<Result> AutomaticGainControlEffect::setAudioSource(const AudioSource& source) {
+    return mEffect->setAudioSource(source);
+}
+
+Return<Result> AutomaticGainControlEffect::setDevice(const DeviceAddress& device) {
+    return mEffect->setDevice(device);
+}
+
+Return<Result> AutomaticGainControlEffect::setInputDevice(const DeviceAddress& device) {
+    return mEffect->setInputDevice(device);
+}
+#endif
+
 Return<void> AutomaticGainControlEffect::setAndGetVolume(const hidl_vec<uint32_t>& volumes,
                                                          setAndGetVolume_cb _hidl_cb) {
     return mEffect->setAndGetVolume(volumes, _hidl_cb);
@@ -95,10 +115,6 @@
     return mEffect->setConfigReverse(config, inputBufferProvider, outputBufferProvider);
 }
 
-Return<Result> AutomaticGainControlEffect::setInputDevice(AudioDeviceBitfield device) {
-    return mEffect->setInputDevice(device);
-}
-
 Return<void> AutomaticGainControlEffect::getConfig(getConfig_cb _hidl_cb) {
     return mEffect->getConfig(_hidl_cb);
 }
@@ -121,10 +137,6 @@
     return mEffect->setAuxChannelsConfig(config);
 }
 
-Return<Result> AutomaticGainControlEffect::setAudioSource(AudioSource source) {
-    return mEffect->setAudioSource(source);
-}
-
 Return<Result> AutomaticGainControlEffect::offload(const EffectOffloadParameter& param) {
     return mEffect->offload(param);
 }
diff --git a/audio/effect/all-versions/default/AutomaticGainControlEffect.h b/audio/effect/all-versions/default/AutomaticGainControlEffect.h
index 67e260a..f30d7a5 100644
--- a/audio/effect/all-versions/default/AutomaticGainControlEffect.h
+++ b/audio/effect/all-versions/default/AutomaticGainControlEffect.h
@@ -55,7 +55,15 @@
     Return<Result> reset() override;
     Return<Result> enable() override;
     Return<Result> disable() override;
+#if MAJOR_VERSION <= 6
+    Return<Result> setAudioSource(AudioSource source) override;
     Return<Result> setDevice(AudioDeviceBitfield device) override;
+    Return<Result> setInputDevice(AudioDeviceBitfield device) override;
+#else
+    Return<Result> setAudioSource(const AudioSource& source) override;
+    Return<Result> setDevice(const DeviceAddress& device) override;
+    Return<Result> setInputDevice(const DeviceAddress& device) override;
+#endif
     Return<void> setAndGetVolume(const hidl_vec<uint32_t>& volumes,
                                  setAndGetVolume_cb _hidl_cb) override;
     Return<Result> volumeChangeNotification(const hidl_vec<uint32_t>& volumes) override;
@@ -63,14 +71,12 @@
     Return<Result> setConfigReverse(
         const EffectConfig& config, const sp<IEffectBufferProviderCallback>& inputBufferProvider,
         const sp<IEffectBufferProviderCallback>& outputBufferProvider) override;
-    Return<Result> setInputDevice(AudioDeviceBitfield device) override;
     Return<void> getConfig(getConfig_cb _hidl_cb) override;
     Return<void> getConfigReverse(getConfigReverse_cb _hidl_cb) override;
     Return<void> getSupportedAuxChannelsConfigs(
         uint32_t maxConfigs, getSupportedAuxChannelsConfigs_cb _hidl_cb) override;
     Return<void> getAuxChannelsConfig(getAuxChannelsConfig_cb _hidl_cb) override;
     Return<Result> setAuxChannelsConfig(const EffectAuxChannelsConfig& config) override;
-    Return<Result> setAudioSource(AudioSource source) override;
     Return<Result> offload(const EffectOffloadParameter& param) override;
     Return<void> getDescriptor(getDescriptor_cb _hidl_cb) override;
     Return<void> prepareForProcessing(prepareForProcessing_cb _hidl_cb) override;
@@ -107,7 +113,7 @@
    private:
     sp<Effect> mEffect;
 
-    virtual ~AutomaticGainControlEffect();
+    virtual ~AutomaticGainControlEffect() = default;
 
     void propertiesFromHal(const t_agc_settings& halProperties,
                            IAutomaticGainControlEffect::AllProperties* properties);
diff --git a/audio/effect/all-versions/default/BassBoostEffect.cpp b/audio/effect/all-versions/default/BassBoostEffect.cpp
index 04fd486..33fea3b 100644
--- a/audio/effect/all-versions/default/BassBoostEffect.cpp
+++ b/audio/effect/all-versions/default/BassBoostEffect.cpp
@@ -30,9 +30,8 @@
 namespace CPP_VERSION {
 namespace implementation {
 
-BassBoostEffect::BassBoostEffect(effect_handle_t handle) : mEffect(new Effect(handle)) {}
-
-BassBoostEffect::~BassBoostEffect() {}
+BassBoostEffect::BassBoostEffect(effect_handle_t handle)
+    : mEffect(new Effect(false /*isInput*/, handle)) {}
 
 // Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffect follow.
 Return<Result> BassBoostEffect::init() {
@@ -57,10 +56,32 @@
     return mEffect->disable();
 }
 
+#if MAJOR_VERSION <= 6
+Return<Result> BassBoostEffect::setAudioSource(AudioSource source) {
+    return mEffect->setAudioSource(source);
+}
+
 Return<Result> BassBoostEffect::setDevice(AudioDeviceBitfield device) {
     return mEffect->setDevice(device);
 }
 
+Return<Result> BassBoostEffect::setInputDevice(AudioDeviceBitfield device) {
+    return mEffect->setInputDevice(device);
+}
+#else
+Return<Result> BassBoostEffect::setAudioSource(const AudioSource& source) {
+    return mEffect->setAudioSource(source);
+}
+
+Return<Result> BassBoostEffect::setDevice(const DeviceAddress& device) {
+    return mEffect->setDevice(device);
+}
+
+Return<Result> BassBoostEffect::setInputDevice(const DeviceAddress& device) {
+    return mEffect->setInputDevice(device);
+}
+#endif
+
 Return<void> BassBoostEffect::setAndGetVolume(const hidl_vec<uint32_t>& volumes,
                                               setAndGetVolume_cb _hidl_cb) {
     return mEffect->setAndGetVolume(volumes, _hidl_cb);
@@ -80,10 +101,6 @@
     return mEffect->setConfigReverse(config, inputBufferProvider, outputBufferProvider);
 }
 
-Return<Result> BassBoostEffect::setInputDevice(AudioDeviceBitfield device) {
-    return mEffect->setInputDevice(device);
-}
-
 Return<void> BassBoostEffect::getConfig(getConfig_cb _hidl_cb) {
     return mEffect->getConfig(_hidl_cb);
 }
@@ -105,10 +122,6 @@
     return mEffect->setAuxChannelsConfig(config);
 }
 
-Return<Result> BassBoostEffect::setAudioSource(AudioSource source) {
-    return mEffect->setAudioSource(source);
-}
-
 Return<Result> BassBoostEffect::offload(const EffectOffloadParameter& param) {
     return mEffect->offload(param);
 }
diff --git a/audio/effect/all-versions/default/BassBoostEffect.h b/audio/effect/all-versions/default/BassBoostEffect.h
index b89bb22..48f586c 100644
--- a/audio/effect/all-versions/default/BassBoostEffect.h
+++ b/audio/effect/all-versions/default/BassBoostEffect.h
@@ -55,7 +55,15 @@
     Return<Result> reset() override;
     Return<Result> enable() override;
     Return<Result> disable() override;
+#if MAJOR_VERSION <= 6
+    Return<Result> setAudioSource(AudioSource source) override;
     Return<Result> setDevice(AudioDeviceBitfield device) override;
+    Return<Result> setInputDevice(AudioDeviceBitfield device) override;
+#else
+    Return<Result> setAudioSource(const AudioSource& source) override;
+    Return<Result> setDevice(const DeviceAddress& device) override;
+    Return<Result> setInputDevice(const DeviceAddress& device) override;
+#endif
     Return<void> setAndGetVolume(const hidl_vec<uint32_t>& volumes,
                                  setAndGetVolume_cb _hidl_cb) override;
     Return<Result> volumeChangeNotification(const hidl_vec<uint32_t>& volumes) override;
@@ -63,14 +71,12 @@
     Return<Result> setConfigReverse(
         const EffectConfig& config, const sp<IEffectBufferProviderCallback>& inputBufferProvider,
         const sp<IEffectBufferProviderCallback>& outputBufferProvider) override;
-    Return<Result> setInputDevice(AudioDeviceBitfield device) override;
     Return<void> getConfig(getConfig_cb _hidl_cb) override;
     Return<void> getConfigReverse(getConfigReverse_cb _hidl_cb) override;
     Return<void> getSupportedAuxChannelsConfigs(
         uint32_t maxConfigs, getSupportedAuxChannelsConfigs_cb _hidl_cb) override;
     Return<void> getAuxChannelsConfig(getAuxChannelsConfig_cb _hidl_cb) override;
     Return<Result> setAuxChannelsConfig(const EffectAuxChannelsConfig& config) override;
-    Return<Result> setAudioSource(AudioSource source) override;
     Return<Result> offload(const EffectOffloadParameter& param) override;
     Return<void> getDescriptor(getDescriptor_cb _hidl_cb) override;
     Return<void> prepareForProcessing(prepareForProcessing_cb _hidl_cb) override;
@@ -100,7 +106,7 @@
    private:
     sp<Effect> mEffect;
 
-    virtual ~BassBoostEffect();
+    virtual ~BassBoostEffect() = default;
 };
 
 }  // namespace implementation
diff --git a/audio/effect/all-versions/default/DownmixEffect.cpp b/audio/effect/all-versions/default/DownmixEffect.cpp
index c001a5f..f324cff 100644
--- a/audio/effect/all-versions/default/DownmixEffect.cpp
+++ b/audio/effect/all-versions/default/DownmixEffect.cpp
@@ -30,9 +30,8 @@
 namespace CPP_VERSION {
 namespace implementation {
 
-DownmixEffect::DownmixEffect(effect_handle_t handle) : mEffect(new Effect(handle)) {}
-
-DownmixEffect::~DownmixEffect() {}
+DownmixEffect::DownmixEffect(effect_handle_t handle)
+    : mEffect(new Effect(false /*isInput*/, handle)) {}
 
 // Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffect follow.
 Return<Result> DownmixEffect::init() {
@@ -57,10 +56,32 @@
     return mEffect->disable();
 }
 
+#if MAJOR_VERSION <= 6
+Return<Result> DownmixEffect::setAudioSource(AudioSource source) {
+    return mEffect->setAudioSource(source);
+}
+
 Return<Result> DownmixEffect::setDevice(AudioDeviceBitfield device) {
     return mEffect->setDevice(device);
 }
 
+Return<Result> DownmixEffect::setInputDevice(AudioDeviceBitfield device) {
+    return mEffect->setInputDevice(device);
+}
+#else
+Return<Result> DownmixEffect::setAudioSource(const AudioSource& source) {
+    return mEffect->setAudioSource(source);
+}
+
+Return<Result> DownmixEffect::setDevice(const DeviceAddress& device) {
+    return mEffect->setDevice(device);
+}
+
+Return<Result> DownmixEffect::setInputDevice(const DeviceAddress& device) {
+    return mEffect->setInputDevice(device);
+}
+#endif
+
 Return<void> DownmixEffect::setAndGetVolume(const hidl_vec<uint32_t>& volumes,
                                             setAndGetVolume_cb _hidl_cb) {
     return mEffect->setAndGetVolume(volumes, _hidl_cb);
@@ -80,10 +101,6 @@
     return mEffect->setConfigReverse(config, inputBufferProvider, outputBufferProvider);
 }
 
-Return<Result> DownmixEffect::setInputDevice(AudioDeviceBitfield device) {
-    return mEffect->setInputDevice(device);
-}
-
 Return<void> DownmixEffect::getConfig(getConfig_cb _hidl_cb) {
     return mEffect->getConfig(_hidl_cb);
 }
@@ -105,10 +122,6 @@
     return mEffect->setAuxChannelsConfig(config);
 }
 
-Return<Result> DownmixEffect::setAudioSource(AudioSource source) {
-    return mEffect->setAudioSource(source);
-}
-
 Return<Result> DownmixEffect::offload(const EffectOffloadParameter& param) {
     return mEffect->offload(param);
 }
diff --git a/audio/effect/all-versions/default/DownmixEffect.h b/audio/effect/all-versions/default/DownmixEffect.h
index 40e462e..caacd06 100644
--- a/audio/effect/all-versions/default/DownmixEffect.h
+++ b/audio/effect/all-versions/default/DownmixEffect.h
@@ -53,7 +53,15 @@
     Return<Result> reset() override;
     Return<Result> enable() override;
     Return<Result> disable() override;
+#if MAJOR_VERSION <= 6
+    Return<Result> setAudioSource(AudioSource source) override;
     Return<Result> setDevice(AudioDeviceBitfield device) override;
+    Return<Result> setInputDevice(AudioDeviceBitfield device) override;
+#else
+    Return<Result> setAudioSource(const AudioSource& source) override;
+    Return<Result> setDevice(const DeviceAddress& device) override;
+    Return<Result> setInputDevice(const DeviceAddress& device) override;
+#endif
     Return<void> setAndGetVolume(const hidl_vec<uint32_t>& volumes,
                                  setAndGetVolume_cb _hidl_cb) override;
     Return<Result> volumeChangeNotification(const hidl_vec<uint32_t>& volumes) override;
@@ -61,14 +69,12 @@
     Return<Result> setConfigReverse(
         const EffectConfig& config, const sp<IEffectBufferProviderCallback>& inputBufferProvider,
         const sp<IEffectBufferProviderCallback>& outputBufferProvider) override;
-    Return<Result> setInputDevice(AudioDeviceBitfield device) override;
     Return<void> getConfig(getConfig_cb _hidl_cb) override;
     Return<void> getConfigReverse(getConfigReverse_cb _hidl_cb) override;
     Return<void> getSupportedAuxChannelsConfigs(
         uint32_t maxConfigs, getSupportedAuxChannelsConfigs_cb _hidl_cb) override;
     Return<void> getAuxChannelsConfig(getAuxChannelsConfig_cb _hidl_cb) override;
     Return<Result> setAuxChannelsConfig(const EffectAuxChannelsConfig& config) override;
-    Return<Result> setAudioSource(AudioSource source) override;
     Return<Result> offload(const EffectOffloadParameter& param) override;
     Return<void> getDescriptor(getDescriptor_cb _hidl_cb) override;
     Return<void> prepareForProcessing(prepareForProcessing_cb _hidl_cb) override;
@@ -97,7 +103,7 @@
    private:
     sp<Effect> mEffect;
 
-    virtual ~DownmixEffect();
+    virtual ~DownmixEffect() = default;
 };
 
 }  // namespace implementation
diff --git a/audio/effect/all-versions/default/Effect.cpp b/audio/effect/all-versions/default/Effect.cpp
index 406a571..edd364c 100644
--- a/audio/effect/all-versions/default/Effect.cpp
+++ b/audio/effect/all-versions/default/Effect.cpp
@@ -27,6 +27,7 @@
 
 #define ATRACE_TAG ATRACE_TAG_AUDIO
 
+#include <HidlUtils.h>
 #include <android/log.h>
 #include <media/EffectsFactoryApi.h>
 #include <utils/Trace.h>
@@ -40,7 +41,10 @@
 namespace CPP_VERSION {
 namespace implementation {
 
+#if MAJOR_VERSION <= 6
 using ::android::hardware::audio::common::CPP_VERSION::implementation::AudioChannelBitfield;
+#endif
+using ::android::hardware::audio::common::CPP_VERSION::implementation::HidlUtils;
 
 namespace {
 
@@ -136,9 +140,12 @@
 const char* Effect::sContextResultOfCommand = "returned status";
 const char* Effect::sContextCallToCommand = "error";
 const char* Effect::sContextCallFunction = sContextCallToCommand;
+const char* Effect::sContextConversion = "conversion";
 
-Effect::Effect(effect_handle_t handle)
-    : mHandle(handle), mEfGroup(nullptr), mStopProcessThread(false) {}
+Effect::Effect(bool isInput, effect_handle_t handle)
+    : mIsInput(isInput), mHandle(handle), mEfGroup(nullptr), mStopProcessThread(false) {
+    (void)mIsInput;  // prevent 'unused field' warnings in pre-V7 versions.
+}
 
 Effect::~Effect() {
     ATRACE_CALL();
@@ -180,7 +187,8 @@
     return halData;
 }
 
-// static
+#if MAJOR_VERSION <= 6
+
 void Effect::effectAuxChannelsConfigFromHal(const channel_config_t& halConfig,
                                             EffectAuxChannelsConfig* config) {
     config->mainChannels = AudioChannelBitfield(halConfig.main_channels);
@@ -194,7 +202,6 @@
     halConfig->aux_channels = static_cast<audio_channel_mask_t>(config.auxChannels);
 }
 
-// static
 void Effect::effectBufferConfigFromHal(const buffer_config_t& halConfig,
                                        EffectBufferConfig* config) {
     config->buffer.id = 0;
@@ -223,7 +230,56 @@
     halConfig->mask = static_cast<uint8_t>(config.mask);
 }
 
+#else  // MAJOR_VERSION <= 6
+
+void Effect::effectAuxChannelsConfigFromHal(const channel_config_t& halConfig,
+                                            EffectAuxChannelsConfig* config) {
+    (void)HidlUtils::audioChannelMaskFromHal(halConfig.main_channels, mIsInput,
+                                             &config->mainChannels);
+    (void)HidlUtils::audioChannelMaskFromHal(halConfig.aux_channels, mIsInput,
+                                             &config->auxChannels);
+}
+
 // static
+void Effect::effectAuxChannelsConfigToHal(const EffectAuxChannelsConfig& config,
+                                          channel_config_t* halConfig) {
+    (void)HidlUtils::audioChannelMaskToHal(config.mainChannels, &halConfig->main_channels);
+    (void)HidlUtils::audioChannelMaskToHal(config.auxChannels, &halConfig->aux_channels);
+}
+
+void Effect::effectBufferConfigFromHal(const buffer_config_t& halConfig,
+                                       EffectBufferConfig* config) {
+    config->buffer.id = 0;
+    config->buffer.frameCount = 0;
+    audio_config_base_t halConfigBase = {halConfig.samplingRate,
+                                         static_cast<audio_channel_mask_t>(halConfig.channels),
+                                         static_cast<audio_format_t>(halConfig.format)};
+    (void)HidlUtils::audioConfigBaseFromHal(halConfigBase, mIsInput, &config->base);
+    config->accessMode = EffectBufferAccess(halConfig.accessMode);
+    config->mask = static_cast<decltype(config->mask)>(halConfig.mask);
+}
+
+// static
+void Effect::effectBufferConfigToHal(const EffectBufferConfig& config, buffer_config_t* halConfig) {
+    // Note: setting the buffers directly is considered obsolete. They need to be set
+    // using 'setProcessBuffers'.
+    halConfig->buffer.frameCount = 0;
+    halConfig->buffer.raw = nullptr;
+    audio_config_base_t halConfigBase;
+    (void)HidlUtils::audioConfigBaseToHal(config.base, &halConfigBase);
+    halConfig->samplingRate = halConfigBase.sample_rate;
+    halConfig->channels = halConfigBase.channel_mask;
+    halConfig->format = halConfigBase.format;
+    // Note: The framework code does not use BP.
+    halConfig->bufferProvider.cookie = nullptr;
+    halConfig->bufferProvider.getBuffer = nullptr;
+    halConfig->bufferProvider.releaseBuffer = nullptr;
+    halConfig->accessMode = static_cast<uint8_t>(config.accessMode);
+    halConfig->mask = static_cast<uint8_t>(config.mask);
+}
+
+#endif  // MAJOR_VERSION <= 6
+
 void Effect::effectConfigFromHal(const effect_config_t& halConfig, EffectConfig* config) {
     effectBufferConfigFromHal(halConfig.inputCfg, &config->inputCfg);
     effectBufferConfigFromHal(halConfig.outputCfg, &config->outputCfg);
@@ -507,11 +563,65 @@
     return sendCommandReturningStatus(EFFECT_CMD_DISABLE, "DISABLE");
 }
 
+Return<Result> Effect::setAudioSource(
+#if MAJOR_VERSION <= 6
+        AudioSource source
+#else
+        const AudioSource& source
+#endif
+) {
+    audio_source_t halSource;
+    if (status_t status = HidlUtils::audioSourceToHal(source, &halSource); status == NO_ERROR) {
+        uint32_t halSourceParam = static_cast<uint32_t>(halSource);
+        return sendCommand(EFFECT_CMD_SET_AUDIO_SOURCE, "SET_AUDIO_SOURCE", sizeof(uint32_t),
+                           &halSourceParam);
+    } else {
+        return analyzeStatus(__func__, "audioSourceToHal", sContextConversion, status);
+    }
+}
+
+#if MAJOR_VERSION <= 6
+
 Return<Result> Effect::setDevice(AudioDeviceBitfield device) {
     uint32_t halDevice = static_cast<uint32_t>(device);
     return sendCommand(EFFECT_CMD_SET_DEVICE, "SET_DEVICE", sizeof(uint32_t), &halDevice);
 }
 
+Return<Result> Effect::setInputDevice(AudioDeviceBitfield device) {
+    uint32_t halDevice = static_cast<uint32_t>(device);
+    return sendCommand(EFFECT_CMD_SET_INPUT_DEVICE, "SET_INPUT_DEVICE", sizeof(uint32_t),
+                       &halDevice);
+}
+
+#else  // MAJOR_VERSION <= 6
+
+Return<Result> Effect::setDevice(const DeviceAddress& device) {
+    audio_devices_t halDevice;
+    char halDeviceAddress[AUDIO_DEVICE_MAX_ADDRESS_LEN];
+    if (status_t status = HidlUtils::deviceAddressToHal(device, &halDevice, halDeviceAddress);
+        status == NO_ERROR) {
+        uint32_t halDeviceParam = static_cast<uint32_t>(halDevice);
+        return sendCommand(EFFECT_CMD_SET_DEVICE, "SET_DEVICE", sizeof(uint32_t), &halDeviceParam);
+    } else {
+        return analyzeStatus(__func__, "deviceAddressToHal", sContextConversion, status);
+    }
+}
+
+Return<Result> Effect::setInputDevice(const DeviceAddress& device) {
+    audio_devices_t halDevice;
+    char halDeviceAddress[AUDIO_DEVICE_MAX_ADDRESS_LEN];
+    if (status_t status = HidlUtils::deviceAddressToHal(device, &halDevice, halDeviceAddress);
+        status == NO_ERROR) {
+        uint32_t halDeviceParam = static_cast<uint32_t>(halDevice);
+        return sendCommand(EFFECT_CMD_SET_INPUT_DEVICE, "SET_INPUT_DEVICE", sizeof(uint32_t),
+                           &halDeviceParam);
+    } else {
+        return analyzeStatus(__func__, "deviceAddressToHal", sContextConversion, status);
+    }
+}
+
+#endif  // MAJOR_VERSION <= 6
+
 Return<void> Effect::setAndGetVolume(const hidl_vec<uint32_t>& volumes,
                                      setAndGetVolume_cb _hidl_cb) {
     uint32_t halDataSize;
@@ -546,12 +656,6 @@
                          inputBufferProvider, outputBufferProvider);
 }
 
-Return<Result> Effect::setInputDevice(AudioDeviceBitfield device) {
-    uint32_t halDevice = static_cast<uint32_t>(device);
-    return sendCommand(EFFECT_CMD_SET_INPUT_DEVICE, "SET_INPUT_DEVICE", sizeof(uint32_t),
-                       &halDevice);
-}
-
 Return<void> Effect::getConfig(getConfig_cb _hidl_cb) {
     getConfigImpl(EFFECT_CMD_GET_CONFIG, "GET_CONFIG", _hidl_cb);
     return Void();
@@ -598,12 +702,6 @@
                                       "SET_FEATURE_CONFIG AUX_CHANNELS", halCmd.size(), &halCmd[0]);
 }
 
-Return<Result> Effect::setAudioSource(AudioSource source) {
-    uint32_t halSource = static_cast<uint32_t>(source);
-    return sendCommand(EFFECT_CMD_SET_AUDIO_SOURCE, "SET_AUDIO_SOURCE", sizeof(uint32_t),
-                       &halSource);
-}
-
 Return<Result> Effect::offload(const EffectOffloadParameter& param) {
     effect_offload_param_t halParam;
     effectOffloadParamToHal(param, &halParam);
diff --git a/audio/effect/all-versions/default/Effect.h b/audio/effect/all-versions/default/Effect.h
index 181e542..9aa47ea 100644
--- a/audio/effect/all-versions/default/Effect.h
+++ b/audio/effect/all-versions/default/Effect.h
@@ -47,7 +47,9 @@
 using ::android::hardware::hidl_vec;
 using ::android::hardware::Return;
 using ::android::hardware::Void;
+#if MAJOR_VERSION <= 6
 using ::android::hardware::audio::common::CPP_VERSION::implementation::AudioDeviceBitfield;
+#endif
 using namespace ::android::hardware::audio::common::CPP_VERSION;
 using namespace ::android::hardware::audio::effect::CPP_VERSION;
 
@@ -56,7 +58,7 @@
     using GetParameterSuccessCallback =
         std::function<void(uint32_t valueSize, const void* valueData)>;
 
-    explicit Effect(effect_handle_t handle);
+    Effect(bool isInput, effect_handle_t handle);
 
     // Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffect follow.
     Return<Result> init() override;
@@ -66,7 +68,15 @@
     Return<Result> reset() override;
     Return<Result> enable() override;
     Return<Result> disable() override;
+#if MAJOR_VERSION <= 6
+    Return<Result> setAudioSource(AudioSource source) override;
     Return<Result> setDevice(AudioDeviceBitfield device) override;
+    Return<Result> setInputDevice(AudioDeviceBitfield device) override;
+#else
+    Return<Result> setAudioSource(const AudioSource& source) override;
+    Return<Result> setDevice(const DeviceAddress& device) override;
+    Return<Result> setInputDevice(const DeviceAddress& device) override;
+#endif
     Return<void> setAndGetVolume(const hidl_vec<uint32_t>& volumes,
                                  setAndGetVolume_cb _hidl_cb) override;
     Return<Result> volumeChangeNotification(const hidl_vec<uint32_t>& volumes) override;
@@ -74,14 +84,12 @@
     Return<Result> setConfigReverse(
         const EffectConfig& config, const sp<IEffectBufferProviderCallback>& inputBufferProvider,
         const sp<IEffectBufferProviderCallback>& outputBufferProvider) override;
-    Return<Result> setInputDevice(AudioDeviceBitfield device) override;
     Return<void> getConfig(getConfig_cb _hidl_cb) override;
     Return<void> getConfigReverse(getConfigReverse_cb _hidl_cb) override;
     Return<void> getSupportedAuxChannelsConfigs(
         uint32_t maxConfigs, getSupportedAuxChannelsConfigs_cb _hidl_cb) override;
     Return<void> getAuxChannelsConfig(getAuxChannelsConfig_cb _hidl_cb) override;
     Return<Result> setAuxChannelsConfig(const EffectAuxChannelsConfig& config) override;
-    Return<Result> setAudioSource(AudioSource source) override;
     Return<Result> offload(const EffectOffloadParameter& param) override;
     Return<void> getDescriptor(getDescriptor_cb _hidl_cb) override;
     Return<void> prepareForProcessing(prepareForProcessing_cb _hidl_cb) override;
@@ -104,6 +112,10 @@
     Return<void> debug(const hidl_handle& fd, const hidl_vec<hidl_string>& options) override;
 
     // Utility methods for extending interfaces.
+    static const char* sContextConversion;
+
+    Result analyzeStatus(const char* funcName, const char* subFuncName,
+                         const char* contextDescription, status_t status);
     template <typename T>
     Return<void> getIntegerParam(uint32_t paramId,
                                  std::function<void(Result retval, T paramValue)> cb) {
@@ -170,6 +182,7 @@
     static const char* sContextCallToCommand;
     static const char* sContextCallFunction;
 
+    const bool mIsInput;
     effect_handle_t mHandle;
     sp<AudioBufferWrapper> mInBuffer;
     sp<AudioBufferWrapper> mOutBuffer;
@@ -186,15 +199,14 @@
     static size_t alignedSizeIn(size_t s);
     template <typename T>
     std::unique_ptr<uint8_t[]> hidlVecToHal(const hidl_vec<T>& vec, uint32_t* halDataSize);
-    static void effectAuxChannelsConfigFromHal(const channel_config_t& halConfig,
-                                               EffectAuxChannelsConfig* config);
+    void effectAuxChannelsConfigFromHal(const channel_config_t& halConfig,
+                                        EffectAuxChannelsConfig* config);
     static void effectAuxChannelsConfigToHal(const EffectAuxChannelsConfig& config,
                                              channel_config_t* halConfig);
-    static void effectBufferConfigFromHal(const buffer_config_t& halConfig,
-                                          EffectBufferConfig* config);
+    void effectBufferConfigFromHal(const buffer_config_t& halConfig, EffectBufferConfig* config);
     static void effectBufferConfigToHal(const EffectBufferConfig& config,
                                         buffer_config_t* halConfig);
-    static void effectConfigFromHal(const effect_config_t& halConfig, EffectConfig* config);
+    void effectConfigFromHal(const effect_config_t& halConfig, EffectConfig* config);
     static void effectConfigToHal(const EffectConfig& config, effect_config_t* halConfig);
     static void effectOffloadParamToHal(const EffectOffloadParameter& offload,
                                         effect_offload_param_t* halOffload);
@@ -202,8 +214,6 @@
                                                uint32_t valueSize, const void** valueData);
 
     Result analyzeCommandStatus(const char* commandName, const char* context, status_t status);
-    Result analyzeStatus(const char* funcName, const char* subFuncName,
-                         const char* contextDescription, status_t status);
     void getConfigImpl(int commandCode, const char* commandName, GetConfigCallback cb);
     Result getCurrentConfigImpl(uint32_t featureId, uint32_t configSize,
                                 GetCurrentConfigSuccessCallback onSuccess);
diff --git a/audio/effect/all-versions/default/EffectsFactory.cpp b/audio/effect/all-versions/default/EffectsFactory.cpp
index b265d3d..1ea990b 100644
--- a/audio/effect/all-versions/default/EffectsFactory.cpp
+++ b/audio/effect/all-versions/default/EffectsFactory.cpp
@@ -82,7 +82,9 @@
     } else if (memcmp(halUuid, SL_IID_VISUALIZATION, sizeof(effect_uuid_t)) == 0) {
         return new VisualizerEffect(handle);
     }
-    return new Effect(handle);
+    const bool isInput =
+            (halDescriptor.flags & EFFECT_FLAG_TYPE_PRE_PROC) == EFFECT_FLAG_TYPE_PRE_PROC;
+    return new Effect(isInput, handle);
 }
 
 // Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffectsFactory follow.
diff --git a/audio/effect/all-versions/default/EnvironmentalReverbEffect.cpp b/audio/effect/all-versions/default/EnvironmentalReverbEffect.cpp
index 78122d4..e95a267 100644
--- a/audio/effect/all-versions/default/EnvironmentalReverbEffect.cpp
+++ b/audio/effect/all-versions/default/EnvironmentalReverbEffect.cpp
@@ -31,9 +31,7 @@
 namespace implementation {
 
 EnvironmentalReverbEffect::EnvironmentalReverbEffect(effect_handle_t handle)
-    : mEffect(new Effect(handle)) {}
-
-EnvironmentalReverbEffect::~EnvironmentalReverbEffect() {}
+    : mEffect(new Effect(false /*isInput*/, handle)) {}
 
 void EnvironmentalReverbEffect::propertiesFromHal(
     const t_reverb_settings& halProperties, IEnvironmentalReverbEffect::AllProperties* properties) {
@@ -86,10 +84,32 @@
     return mEffect->disable();
 }
 
+#if MAJOR_VERSION <= 6
+Return<Result> EnvironmentalReverbEffect::setAudioSource(AudioSource source) {
+    return mEffect->setAudioSource(source);
+}
+
 Return<Result> EnvironmentalReverbEffect::setDevice(AudioDeviceBitfield device) {
     return mEffect->setDevice(device);
 }
 
+Return<Result> EnvironmentalReverbEffect::setInputDevice(AudioDeviceBitfield device) {
+    return mEffect->setInputDevice(device);
+}
+#else
+Return<Result> EnvironmentalReverbEffect::setAudioSource(const AudioSource& source) {
+    return mEffect->setAudioSource(source);
+}
+
+Return<Result> EnvironmentalReverbEffect::setDevice(const DeviceAddress& device) {
+    return mEffect->setDevice(device);
+}
+
+Return<Result> EnvironmentalReverbEffect::setInputDevice(const DeviceAddress& device) {
+    return mEffect->setInputDevice(device);
+}
+#endif
+
 Return<void> EnvironmentalReverbEffect::setAndGetVolume(const hidl_vec<uint32_t>& volumes,
                                                         setAndGetVolume_cb _hidl_cb) {
     return mEffect->setAndGetVolume(volumes, _hidl_cb);
@@ -110,10 +130,6 @@
     return mEffect->setConfigReverse(config, inputBufferProvider, outputBufferProvider);
 }
 
-Return<Result> EnvironmentalReverbEffect::setInputDevice(AudioDeviceBitfield device) {
-    return mEffect->setInputDevice(device);
-}
-
 Return<void> EnvironmentalReverbEffect::getConfig(getConfig_cb _hidl_cb) {
     return mEffect->getConfig(_hidl_cb);
 }
@@ -136,10 +152,6 @@
     return mEffect->setAuxChannelsConfig(config);
 }
 
-Return<Result> EnvironmentalReverbEffect::setAudioSource(AudioSource source) {
-    return mEffect->setAudioSource(source);
-}
-
 Return<Result> EnvironmentalReverbEffect::offload(const EffectOffloadParameter& param) {
     return mEffect->offload(param);
 }
diff --git a/audio/effect/all-versions/default/EnvironmentalReverbEffect.h b/audio/effect/all-versions/default/EnvironmentalReverbEffect.h
index bb422d4..9694b5d 100644
--- a/audio/effect/all-versions/default/EnvironmentalReverbEffect.h
+++ b/audio/effect/all-versions/default/EnvironmentalReverbEffect.h
@@ -57,7 +57,15 @@
     Return<Result> reset() override;
     Return<Result> enable() override;
     Return<Result> disable() override;
+#if MAJOR_VERSION <= 6
+    Return<Result> setAudioSource(AudioSource source) override;
     Return<Result> setDevice(AudioDeviceBitfield device) override;
+    Return<Result> setInputDevice(AudioDeviceBitfield device) override;
+#else
+    Return<Result> setAudioSource(const AudioSource& source) override;
+    Return<Result> setDevice(const DeviceAddress& device) override;
+    Return<Result> setInputDevice(const DeviceAddress& device) override;
+#endif
     Return<void> setAndGetVolume(const hidl_vec<uint32_t>& volumes,
                                  setAndGetVolume_cb _hidl_cb) override;
     Return<Result> volumeChangeNotification(const hidl_vec<uint32_t>& volumes) override;
@@ -65,14 +73,12 @@
     Return<Result> setConfigReverse(
         const EffectConfig& config, const sp<IEffectBufferProviderCallback>& inputBufferProvider,
         const sp<IEffectBufferProviderCallback>& outputBufferProvider) override;
-    Return<Result> setInputDevice(AudioDeviceBitfield device) override;
     Return<void> getConfig(getConfig_cb _hidl_cb) override;
     Return<void> getConfigReverse(getConfigReverse_cb _hidl_cb) override;
     Return<void> getSupportedAuxChannelsConfigs(
         uint32_t maxConfigs, getSupportedAuxChannelsConfigs_cb _hidl_cb) override;
     Return<void> getAuxChannelsConfig(getAuxChannelsConfig_cb _hidl_cb) override;
     Return<Result> setAuxChannelsConfig(const EffectAuxChannelsConfig& config) override;
-    Return<Result> setAudioSource(AudioSource source) override;
     Return<Result> offload(const EffectOffloadParameter& param) override;
     Return<void> getDescriptor(getDescriptor_cb _hidl_cb) override;
     Return<void> prepareForProcessing(prepareForProcessing_cb _hidl_cb) override;
@@ -125,7 +131,7 @@
    private:
     sp<Effect> mEffect;
 
-    virtual ~EnvironmentalReverbEffect();
+    virtual ~EnvironmentalReverbEffect() = default;
 
     void propertiesFromHal(const t_reverb_settings& halProperties,
                            IEnvironmentalReverbEffect::AllProperties* properties);
diff --git a/audio/effect/all-versions/default/EqualizerEffect.cpp b/audio/effect/all-versions/default/EqualizerEffect.cpp
index 1b983ec..fffe8cd 100644
--- a/audio/effect/all-versions/default/EqualizerEffect.cpp
+++ b/audio/effect/all-versions/default/EqualizerEffect.cpp
@@ -31,9 +31,8 @@
 namespace CPP_VERSION {
 namespace implementation {
 
-EqualizerEffect::EqualizerEffect(effect_handle_t handle) : mEffect(new Effect(handle)) {}
-
-EqualizerEffect::~EqualizerEffect() {}
+EqualizerEffect::EqualizerEffect(effect_handle_t handle)
+    : mEffect(new Effect(false /*isInput*/, handle)) {}
 
 void EqualizerEffect::propertiesFromHal(const t_equalizer_settings& halProperties,
                                         IEqualizerEffect::AllProperties* properties) {
@@ -80,10 +79,32 @@
     return mEffect->disable();
 }
 
+#if MAJOR_VERSION <= 6
+Return<Result> EqualizerEffect::setAudioSource(AudioSource source) {
+    return mEffect->setAudioSource(source);
+}
+
 Return<Result> EqualizerEffect::setDevice(AudioDeviceBitfield device) {
     return mEffect->setDevice(device);
 }
 
+Return<Result> EqualizerEffect::setInputDevice(AudioDeviceBitfield device) {
+    return mEffect->setInputDevice(device);
+}
+#else
+Return<Result> EqualizerEffect::setAudioSource(const AudioSource& source) {
+    return mEffect->setAudioSource(source);
+}
+
+Return<Result> EqualizerEffect::setDevice(const DeviceAddress& device) {
+    return mEffect->setDevice(device);
+}
+
+Return<Result> EqualizerEffect::setInputDevice(const DeviceAddress& device) {
+    return mEffect->setInputDevice(device);
+}
+#endif
+
 Return<void> EqualizerEffect::setAndGetVolume(const hidl_vec<uint32_t>& volumes,
                                               setAndGetVolume_cb _hidl_cb) {
     return mEffect->setAndGetVolume(volumes, _hidl_cb);
@@ -103,10 +124,6 @@
     return mEffect->setConfigReverse(config, inputBufferProvider, outputBufferProvider);
 }
 
-Return<Result> EqualizerEffect::setInputDevice(AudioDeviceBitfield device) {
-    return mEffect->setInputDevice(device);
-}
-
 Return<void> EqualizerEffect::getConfig(getConfig_cb _hidl_cb) {
     return mEffect->getConfig(_hidl_cb);
 }
@@ -128,10 +145,6 @@
     return mEffect->setAuxChannelsConfig(config);
 }
 
-Return<Result> EqualizerEffect::setAudioSource(AudioSource source) {
-    return mEffect->setAudioSource(source);
-}
-
 Return<Result> EqualizerEffect::offload(const EffectOffloadParameter& param) {
     return mEffect->offload(param);
 }
diff --git a/audio/effect/all-versions/default/EqualizerEffect.h b/audio/effect/all-versions/default/EqualizerEffect.h
index b1cbefd..7a6bc0a 100644
--- a/audio/effect/all-versions/default/EqualizerEffect.h
+++ b/audio/effect/all-versions/default/EqualizerEffect.h
@@ -57,7 +57,15 @@
     Return<Result> reset() override;
     Return<Result> enable() override;
     Return<Result> disable() override;
+#if MAJOR_VERSION <= 6
+    Return<Result> setAudioSource(AudioSource source) override;
     Return<Result> setDevice(AudioDeviceBitfield device) override;
+    Return<Result> setInputDevice(AudioDeviceBitfield device) override;
+#else
+    Return<Result> setAudioSource(const AudioSource& source) override;
+    Return<Result> setDevice(const DeviceAddress& device) override;
+    Return<Result> setInputDevice(const DeviceAddress& device) override;
+#endif
     Return<void> setAndGetVolume(const hidl_vec<uint32_t>& volumes,
                                  setAndGetVolume_cb _hidl_cb) override;
     Return<Result> volumeChangeNotification(const hidl_vec<uint32_t>& volumes) override;
@@ -65,14 +73,12 @@
     Return<Result> setConfigReverse(
         const EffectConfig& config, const sp<IEffectBufferProviderCallback>& inputBufferProvider,
         const sp<IEffectBufferProviderCallback>& outputBufferProvider) override;
-    Return<Result> setInputDevice(AudioDeviceBitfield device) override;
     Return<void> getConfig(getConfig_cb _hidl_cb) override;
     Return<void> getConfigReverse(getConfigReverse_cb _hidl_cb) override;
     Return<void> getSupportedAuxChannelsConfigs(
         uint32_t maxConfigs, getSupportedAuxChannelsConfigs_cb _hidl_cb) override;
     Return<void> getAuxChannelsConfig(getAuxChannelsConfig_cb _hidl_cb) override;
     Return<Result> setAuxChannelsConfig(const EffectAuxChannelsConfig& config) override;
-    Return<Result> setAudioSource(AudioSource source) override;
     Return<Result> offload(const EffectOffloadParameter& param) override;
     Return<void> getDescriptor(getDescriptor_cb _hidl_cb) override;
     Return<void> prepareForProcessing(prepareForProcessing_cb _hidl_cb) override;
@@ -111,7 +117,7 @@
    private:
     sp<Effect> mEffect;
 
-    virtual ~EqualizerEffect();
+    virtual ~EqualizerEffect() = default;
 
     void propertiesFromHal(const t_equalizer_settings& halProperties,
                            IEqualizerEffect::AllProperties* properties);
diff --git a/audio/effect/all-versions/default/LoudnessEnhancerEffect.cpp b/audio/effect/all-versions/default/LoudnessEnhancerEffect.cpp
index ebd5197..c7add86 100644
--- a/audio/effect/all-versions/default/LoudnessEnhancerEffect.cpp
+++ b/audio/effect/all-versions/default/LoudnessEnhancerEffect.cpp
@@ -33,9 +33,7 @@
 namespace implementation {
 
 LoudnessEnhancerEffect::LoudnessEnhancerEffect(effect_handle_t handle)
-    : mEffect(new Effect(handle)) {}
-
-LoudnessEnhancerEffect::~LoudnessEnhancerEffect() {}
+    : mEffect(new Effect(false /*isInput*/, handle)) {}
 
 // Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffect follow.
 Return<Result> LoudnessEnhancerEffect::init() {
@@ -60,10 +58,32 @@
     return mEffect->disable();
 }
 
+#if MAJOR_VERSION <= 6
+Return<Result> LoudnessEnhancerEffect::setAudioSource(AudioSource source) {
+    return mEffect->setAudioSource(source);
+}
+
 Return<Result> LoudnessEnhancerEffect::setDevice(AudioDeviceBitfield device) {
     return mEffect->setDevice(device);
 }
 
+Return<Result> LoudnessEnhancerEffect::setInputDevice(AudioDeviceBitfield device) {
+    return mEffect->setInputDevice(device);
+}
+#else
+Return<Result> LoudnessEnhancerEffect::setAudioSource(const AudioSource& source) {
+    return mEffect->setAudioSource(source);
+}
+
+Return<Result> LoudnessEnhancerEffect::setDevice(const DeviceAddress& device) {
+    return mEffect->setDevice(device);
+}
+
+Return<Result> LoudnessEnhancerEffect::setInputDevice(const DeviceAddress& device) {
+    return mEffect->setInputDevice(device);
+}
+#endif
+
 Return<void> LoudnessEnhancerEffect::setAndGetVolume(const hidl_vec<uint32_t>& volumes,
                                                      setAndGetVolume_cb _hidl_cb) {
     return mEffect->setAndGetVolume(volumes, _hidl_cb);
@@ -83,10 +103,6 @@
     return mEffect->setConfigReverse(config, inputBufferProvider, outputBufferProvider);
 }
 
-Return<Result> LoudnessEnhancerEffect::setInputDevice(AudioDeviceBitfield device) {
-    return mEffect->setInputDevice(device);
-}
-
 Return<void> LoudnessEnhancerEffect::getConfig(getConfig_cb _hidl_cb) {
     return mEffect->getConfig(_hidl_cb);
 }
@@ -108,10 +124,6 @@
     return mEffect->setAuxChannelsConfig(config);
 }
 
-Return<Result> LoudnessEnhancerEffect::setAudioSource(AudioSource source) {
-    return mEffect->setAudioSource(source);
-}
-
 Return<Result> LoudnessEnhancerEffect::offload(const EffectOffloadParameter& param) {
     return mEffect->offload(param);
 }
diff --git a/audio/effect/all-versions/default/LoudnessEnhancerEffect.h b/audio/effect/all-versions/default/LoudnessEnhancerEffect.h
index 8baf128..6d80207 100644
--- a/audio/effect/all-versions/default/LoudnessEnhancerEffect.h
+++ b/audio/effect/all-versions/default/LoudnessEnhancerEffect.h
@@ -53,7 +53,15 @@
     Return<Result> reset() override;
     Return<Result> enable() override;
     Return<Result> disable() override;
+#if MAJOR_VERSION <= 6
+    Return<Result> setAudioSource(AudioSource source) override;
     Return<Result> setDevice(AudioDeviceBitfield device) override;
+    Return<Result> setInputDevice(AudioDeviceBitfield device) override;
+#else
+    Return<Result> setAudioSource(const AudioSource& source) override;
+    Return<Result> setDevice(const DeviceAddress& device) override;
+    Return<Result> setInputDevice(const DeviceAddress& device) override;
+#endif
     Return<void> setAndGetVolume(const hidl_vec<uint32_t>& volumes,
                                  setAndGetVolume_cb _hidl_cb) override;
     Return<Result> volumeChangeNotification(const hidl_vec<uint32_t>& volumes) override;
@@ -61,14 +69,12 @@
     Return<Result> setConfigReverse(
         const EffectConfig& config, const sp<IEffectBufferProviderCallback>& inputBufferProvider,
         const sp<IEffectBufferProviderCallback>& outputBufferProvider) override;
-    Return<Result> setInputDevice(AudioDeviceBitfield device) override;
     Return<void> getConfig(getConfig_cb _hidl_cb) override;
     Return<void> getConfigReverse(getConfigReverse_cb _hidl_cb) override;
     Return<void> getSupportedAuxChannelsConfigs(
         uint32_t maxConfigs, getSupportedAuxChannelsConfigs_cb _hidl_cb) override;
     Return<void> getAuxChannelsConfig(getAuxChannelsConfig_cb _hidl_cb) override;
     Return<Result> setAuxChannelsConfig(const EffectAuxChannelsConfig& config) override;
-    Return<Result> setAudioSource(AudioSource source) override;
     Return<Result> offload(const EffectOffloadParameter& param) override;
     Return<void> getDescriptor(getDescriptor_cb _hidl_cb) override;
     Return<void> prepareForProcessing(prepareForProcessing_cb _hidl_cb) override;
@@ -98,7 +104,7 @@
    private:
     sp<Effect> mEffect;
 
-    virtual ~LoudnessEnhancerEffect();
+    virtual ~LoudnessEnhancerEffect() = default;
 };
 
 }  // namespace implementation
diff --git a/audio/effect/all-versions/default/NoiseSuppressionEffect.cpp b/audio/effect/all-versions/default/NoiseSuppressionEffect.cpp
index d01bbe5..9e75237 100644
--- a/audio/effect/all-versions/default/NoiseSuppressionEffect.cpp
+++ b/audio/effect/all-versions/default/NoiseSuppressionEffect.cpp
@@ -30,9 +30,7 @@
 namespace implementation {
 
 NoiseSuppressionEffect::NoiseSuppressionEffect(effect_handle_t handle)
-    : mEffect(new Effect(handle)) {}
-
-NoiseSuppressionEffect::~NoiseSuppressionEffect() {}
+    : mEffect(new Effect(true /*isInput*/, handle)) {}
 
 void NoiseSuppressionEffect::propertiesFromHal(const t_ns_settings& halProperties,
                                                INoiseSuppressionEffect::AllProperties* properties) {
@@ -69,10 +67,32 @@
     return mEffect->disable();
 }
 
+#if MAJOR_VERSION <= 6
+Return<Result> NoiseSuppressionEffect::setAudioSource(AudioSource source) {
+    return mEffect->setAudioSource(source);
+}
+
 Return<Result> NoiseSuppressionEffect::setDevice(AudioDeviceBitfield device) {
     return mEffect->setDevice(device);
 }
 
+Return<Result> NoiseSuppressionEffect::setInputDevice(AudioDeviceBitfield device) {
+    return mEffect->setInputDevice(device);
+}
+#else
+Return<Result> NoiseSuppressionEffect::setAudioSource(const AudioSource& source) {
+    return mEffect->setAudioSource(source);
+}
+
+Return<Result> NoiseSuppressionEffect::setDevice(const DeviceAddress& device) {
+    return mEffect->setDevice(device);
+}
+
+Return<Result> NoiseSuppressionEffect::setInputDevice(const DeviceAddress& device) {
+    return mEffect->setInputDevice(device);
+}
+#endif
+
 Return<void> NoiseSuppressionEffect::setAndGetVolume(const hidl_vec<uint32_t>& volumes,
                                                      setAndGetVolume_cb _hidl_cb) {
     return mEffect->setAndGetVolume(volumes, _hidl_cb);
@@ -92,10 +112,6 @@
     return mEffect->setConfigReverse(config, inputBufferProvider, outputBufferProvider);
 }
 
-Return<Result> NoiseSuppressionEffect::setInputDevice(AudioDeviceBitfield device) {
-    return mEffect->setInputDevice(device);
-}
-
 Return<void> NoiseSuppressionEffect::getConfig(getConfig_cb _hidl_cb) {
     return mEffect->getConfig(_hidl_cb);
 }
@@ -117,10 +133,6 @@
     return mEffect->setAuxChannelsConfig(config);
 }
 
-Return<Result> NoiseSuppressionEffect::setAudioSource(AudioSource source) {
-    return mEffect->setAudioSource(source);
-}
-
 Return<Result> NoiseSuppressionEffect::offload(const EffectOffloadParameter& param) {
     return mEffect->offload(param);
 }
diff --git a/audio/effect/all-versions/default/NoiseSuppressionEffect.h b/audio/effect/all-versions/default/NoiseSuppressionEffect.h
index c49bf7b..6cc45b9 100644
--- a/audio/effect/all-versions/default/NoiseSuppressionEffect.h
+++ b/audio/effect/all-versions/default/NoiseSuppressionEffect.h
@@ -55,7 +55,15 @@
     Return<Result> reset() override;
     Return<Result> enable() override;
     Return<Result> disable() override;
+#if MAJOR_VERSION <= 6
+    Return<Result> setAudioSource(AudioSource source) override;
     Return<Result> setDevice(AudioDeviceBitfield device) override;
+    Return<Result> setInputDevice(AudioDeviceBitfield device) override;
+#else
+    Return<Result> setAudioSource(const AudioSource& source) override;
+    Return<Result> setDevice(const DeviceAddress& device) override;
+    Return<Result> setInputDevice(const DeviceAddress& device) override;
+#endif
     Return<void> setAndGetVolume(const hidl_vec<uint32_t>& volumes,
                                  setAndGetVolume_cb _hidl_cb) override;
     Return<Result> volumeChangeNotification(const hidl_vec<uint32_t>& volumes) override;
@@ -63,14 +71,12 @@
     Return<Result> setConfigReverse(
         const EffectConfig& config, const sp<IEffectBufferProviderCallback>& inputBufferProvider,
         const sp<IEffectBufferProviderCallback>& outputBufferProvider) override;
-    Return<Result> setInputDevice(AudioDeviceBitfield device) override;
     Return<void> getConfig(getConfig_cb _hidl_cb) override;
     Return<void> getConfigReverse(getConfigReverse_cb _hidl_cb) override;
     Return<void> getSupportedAuxChannelsConfigs(
         uint32_t maxConfigs, getSupportedAuxChannelsConfigs_cb _hidl_cb) override;
     Return<void> getAuxChannelsConfig(getAuxChannelsConfig_cb _hidl_cb) override;
     Return<Result> setAuxChannelsConfig(const EffectAuxChannelsConfig& config) override;
-    Return<Result> setAudioSource(AudioSource source) override;
     Return<Result> offload(const EffectOffloadParameter& param) override;
     Return<void> getDescriptor(getDescriptor_cb _hidl_cb) override;
     Return<void> prepareForProcessing(prepareForProcessing_cb _hidl_cb) override;
@@ -105,7 +111,7 @@
    private:
     sp<Effect> mEffect;
 
-    virtual ~NoiseSuppressionEffect();
+    virtual ~NoiseSuppressionEffect() = default;
 
     void propertiesFromHal(const t_ns_settings& halProperties,
                            INoiseSuppressionEffect::AllProperties* properties);
diff --git a/audio/effect/all-versions/default/PresetReverbEffect.cpp b/audio/effect/all-versions/default/PresetReverbEffect.cpp
index 4a2a3a4..1ae8492 100644
--- a/audio/effect/all-versions/default/PresetReverbEffect.cpp
+++ b/audio/effect/all-versions/default/PresetReverbEffect.cpp
@@ -30,9 +30,8 @@
 namespace CPP_VERSION {
 namespace implementation {
 
-PresetReverbEffect::PresetReverbEffect(effect_handle_t handle) : mEffect(new Effect(handle)) {}
-
-PresetReverbEffect::~PresetReverbEffect() {}
+PresetReverbEffect::PresetReverbEffect(effect_handle_t handle)
+    : mEffect(new Effect(false /*isInput*/, handle)) {}
 
 // Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffect follow.
 Return<Result> PresetReverbEffect::init() {
@@ -57,10 +56,32 @@
     return mEffect->disable();
 }
 
+#if MAJOR_VERSION <= 6
+Return<Result> PresetReverbEffect::setAudioSource(AudioSource source) {
+    return mEffect->setAudioSource(source);
+}
+
 Return<Result> PresetReverbEffect::setDevice(AudioDeviceBitfield device) {
     return mEffect->setDevice(device);
 }
 
+Return<Result> PresetReverbEffect::setInputDevice(AudioDeviceBitfield device) {
+    return mEffect->setInputDevice(device);
+}
+#else
+Return<Result> PresetReverbEffect::setAudioSource(const AudioSource& source) {
+    return mEffect->setAudioSource(source);
+}
+
+Return<Result> PresetReverbEffect::setDevice(const DeviceAddress& device) {
+    return mEffect->setDevice(device);
+}
+
+Return<Result> PresetReverbEffect::setInputDevice(const DeviceAddress& device) {
+    return mEffect->setInputDevice(device);
+}
+#endif
+
 Return<void> PresetReverbEffect::setAndGetVolume(const hidl_vec<uint32_t>& volumes,
                                                  setAndGetVolume_cb _hidl_cb) {
     return mEffect->setAndGetVolume(volumes, _hidl_cb);
@@ -80,10 +101,6 @@
     return mEffect->setConfigReverse(config, inputBufferProvider, outputBufferProvider);
 }
 
-Return<Result> PresetReverbEffect::setInputDevice(AudioDeviceBitfield device) {
-    return mEffect->setInputDevice(device);
-}
-
 Return<void> PresetReverbEffect::getConfig(getConfig_cb _hidl_cb) {
     return mEffect->getConfig(_hidl_cb);
 }
@@ -105,10 +122,6 @@
     return mEffect->setAuxChannelsConfig(config);
 }
 
-Return<Result> PresetReverbEffect::setAudioSource(AudioSource source) {
-    return mEffect->setAudioSource(source);
-}
-
 Return<Result> PresetReverbEffect::offload(const EffectOffloadParameter& param) {
     return mEffect->offload(param);
 }
diff --git a/audio/effect/all-versions/default/PresetReverbEffect.h b/audio/effect/all-versions/default/PresetReverbEffect.h
index 58a6829..eb55e20 100644
--- a/audio/effect/all-versions/default/PresetReverbEffect.h
+++ b/audio/effect/all-versions/default/PresetReverbEffect.h
@@ -53,7 +53,15 @@
     Return<Result> reset() override;
     Return<Result> enable() override;
     Return<Result> disable() override;
+#if MAJOR_VERSION <= 6
+    Return<Result> setAudioSource(AudioSource source) override;
     Return<Result> setDevice(AudioDeviceBitfield device) override;
+    Return<Result> setInputDevice(AudioDeviceBitfield device) override;
+#else
+    Return<Result> setAudioSource(const AudioSource& source) override;
+    Return<Result> setDevice(const DeviceAddress& device) override;
+    Return<Result> setInputDevice(const DeviceAddress& device) override;
+#endif
     Return<void> setAndGetVolume(const hidl_vec<uint32_t>& volumes,
                                  setAndGetVolume_cb _hidl_cb) override;
     Return<Result> volumeChangeNotification(const hidl_vec<uint32_t>& volumes) override;
@@ -61,14 +69,12 @@
     Return<Result> setConfigReverse(
         const EffectConfig& config, const sp<IEffectBufferProviderCallback>& inputBufferProvider,
         const sp<IEffectBufferProviderCallback>& outputBufferProvider) override;
-    Return<Result> setInputDevice(AudioDeviceBitfield device) override;
     Return<void> getConfig(getConfig_cb _hidl_cb) override;
     Return<void> getConfigReverse(getConfigReverse_cb _hidl_cb) override;
     Return<void> getSupportedAuxChannelsConfigs(
         uint32_t maxConfigs, getSupportedAuxChannelsConfigs_cb _hidl_cb) override;
     Return<void> getAuxChannelsConfig(getAuxChannelsConfig_cb _hidl_cb) override;
     Return<Result> setAuxChannelsConfig(const EffectAuxChannelsConfig& config) override;
-    Return<Result> setAudioSource(AudioSource source) override;
     Return<Result> offload(const EffectOffloadParameter& param) override;
     Return<void> getDescriptor(getDescriptor_cb _hidl_cb) override;
     Return<void> prepareForProcessing(prepareForProcessing_cb _hidl_cb) override;
@@ -98,7 +104,7 @@
    private:
     sp<Effect> mEffect;
 
-    virtual ~PresetReverbEffect();
+    virtual ~PresetReverbEffect() = default;
 };
 
 }  // namespace implementation
diff --git a/audio/effect/all-versions/default/VirtualizerEffect.cpp b/audio/effect/all-versions/default/VirtualizerEffect.cpp
index 1b69a90..1dce181 100644
--- a/audio/effect/all-versions/default/VirtualizerEffect.cpp
+++ b/audio/effect/all-versions/default/VirtualizerEffect.cpp
@@ -19,7 +19,9 @@
 #include "VirtualizerEffect.h"
 
 #include <memory.h>
+#include <stdlib.h>
 
+#include <HidlUtils.h>
 #include <android/log.h>
 #include <system/audio_effects/effect_virtualizer.h>
 
@@ -32,19 +34,10 @@
 namespace CPP_VERSION {
 namespace implementation {
 
-VirtualizerEffect::VirtualizerEffect(effect_handle_t handle) : mEffect(new Effect(handle)) {}
+using ::android::hardware::audio::common::CPP_VERSION::implementation::HidlUtils;
 
-VirtualizerEffect::~VirtualizerEffect() {}
-
-void VirtualizerEffect::speakerAnglesFromHal(const int32_t* halAngles, uint32_t channelCount,
-                                             hidl_vec<SpeakerAngle>& speakerAngles) {
-    speakerAngles.resize(channelCount);
-    for (uint32_t i = 0; i < channelCount; ++i) {
-        speakerAngles[i].mask = AudioChannelBitfield(*halAngles++);
-        speakerAngles[i].azimuth = *halAngles++;
-        speakerAngles[i].elevation = *halAngles++;
-    }
-}
+VirtualizerEffect::VirtualizerEffect(effect_handle_t handle)
+    : mEffect(new Effect(false /*isInput*/, handle)) {}
 
 // Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffect follow.
 Return<Result> VirtualizerEffect::init() {
@@ -69,10 +62,32 @@
     return mEffect->disable();
 }
 
+#if MAJOR_VERSION <= 6
+Return<Result> VirtualizerEffect::setAudioSource(AudioSource source) {
+    return mEffect->setAudioSource(source);
+}
+
 Return<Result> VirtualizerEffect::setDevice(AudioDeviceBitfield device) {
     return mEffect->setDevice(device);
 }
 
+Return<Result> VirtualizerEffect::setInputDevice(AudioDeviceBitfield device) {
+    return mEffect->setInputDevice(device);
+}
+#else
+Return<Result> VirtualizerEffect::setAudioSource(const AudioSource& source) {
+    return mEffect->setAudioSource(source);
+}
+
+Return<Result> VirtualizerEffect::setDevice(const DeviceAddress& device) {
+    return mEffect->setDevice(device);
+}
+
+Return<Result> VirtualizerEffect::setInputDevice(const DeviceAddress& device) {
+    return mEffect->setInputDevice(device);
+}
+#endif
+
 Return<void> VirtualizerEffect::setAndGetVolume(const hidl_vec<uint32_t>& volumes,
                                                 setAndGetVolume_cb _hidl_cb) {
     return mEffect->setAndGetVolume(volumes, _hidl_cb);
@@ -92,10 +107,6 @@
     return mEffect->setConfigReverse(config, inputBufferProvider, outputBufferProvider);
 }
 
-Return<Result> VirtualizerEffect::setInputDevice(AudioDeviceBitfield device) {
-    return mEffect->setInputDevice(device);
-}
-
 Return<void> VirtualizerEffect::getConfig(getConfig_cb _hidl_cb) {
     return mEffect->getConfig(_hidl_cb);
 }
@@ -117,10 +128,6 @@
     return mEffect->setAuxChannelsConfig(config);
 }
 
-Return<Result> VirtualizerEffect::setAudioSource(AudioSource source) {
-    return mEffect->setAudioSource(source);
-}
-
 Return<Result> VirtualizerEffect::offload(const EffectOffloadParameter& param) {
     return mEffect->offload(param);
 }
@@ -192,43 +199,117 @@
     return mEffect->getIntegerParam(VIRTUALIZER_PARAM_STRENGTH, _hidl_cb);
 }
 
-Return<void> VirtualizerEffect::getVirtualSpeakerAngles(AudioChannelBitfield mask,
-                                                        AudioDevice device,
-                                                        getVirtualSpeakerAngles_cb _hidl_cb) {
-    uint32_t channelCount =
-        audio_channel_count_from_out_mask(static_cast<audio_channel_mask_t>(mask));
+Return<void> VirtualizerEffect::getVirtualSpeakerAngles(
+#if MAJOR_VERSION <= 6
+        AudioChannelBitfield mask, AudioDevice device, getVirtualSpeakerAngles_cb _hidl_cb) {
+    audio_channel_mask_t halChannelMask = static_cast<audio_channel_mask_t>(mask);
+    audio_devices_t halDeviceType = static_cast<audio_devices_t>(device);
+#else
+        const AudioChannelMask& mask, const DeviceAddress& device,
+        getVirtualSpeakerAngles_cb _hidl_cb) {
+    audio_channel_mask_t halChannelMask;
+    if (status_t status = HidlUtils::audioChannelMaskToHal(mask, &halChannelMask);
+        status != NO_ERROR) {
+        _hidl_cb(mEffect->analyzeStatus(__func__, "audioChannelMaskToHal",
+                                        Effect::sContextConversion, status),
+                 SpeakerAngles{});
+        return Void();
+    }
+    audio_devices_t halDeviceType;
+    char halDeviceAddress[AUDIO_DEVICE_MAX_ADDRESS_LEN];
+    if (status_t status = HidlUtils::deviceAddressToHal(device, &halDeviceType, halDeviceAddress);
+        status != NO_ERROR) {
+        _hidl_cb(mEffect->analyzeStatus(__func__, "deviceAddressToHal", Effect::sContextConversion,
+                                        status),
+                 SpeakerAngles{});
+        return Void();
+    }
+#endif
+    uint32_t channelCount = audio_channel_count_from_out_mask(halChannelMask);
     size_t halSpeakerAnglesSize = sizeof(int32_t) * 3 * channelCount;
-    uint32_t halParam[3] = {VIRTUALIZER_PARAM_VIRTUAL_SPEAKER_ANGLES,
-                            static_cast<audio_channel_mask_t>(mask),
-                            static_cast<audio_devices_t>(device)};
-    hidl_vec<SpeakerAngle> speakerAngles;
+    uint32_t halParam[3] = {VIRTUALIZER_PARAM_VIRTUAL_SPEAKER_ANGLES, halChannelMask,
+                            halDeviceType};
+    SpeakerAngles speakerAngles;
+    status_t status = NO_ERROR;
     Result retval = mEffect->getParameterImpl(
-        sizeof(halParam), halParam, halSpeakerAnglesSize,
-        [&](uint32_t valueSize, const void* valueData) {
-            if (valueSize > halSpeakerAnglesSize) {
-                valueSize = halSpeakerAnglesSize;
-            } else if (valueSize < halSpeakerAnglesSize) {
-                channelCount = valueSize / (sizeof(int32_t) * 3);
-            }
-            speakerAnglesFromHal(reinterpret_cast<const int32_t*>(valueData), channelCount,
-                                 speakerAngles);
-        });
+            sizeof(halParam), halParam, halSpeakerAnglesSize,
+            [&](uint32_t valueSize, const void* valueData) {
+                if (valueSize < halSpeakerAnglesSize) {
+                    channelCount = valueSize / (sizeof(int32_t) * 3);
+                }
+                status = speakerAnglesFromHal(reinterpret_cast<const int32_t*>(valueData),
+                                              channelCount, speakerAngles);
+            });
+    if (retval == Result::OK) {
+        retval = mEffect->analyzeStatus(__func__, "speakerAnglesFromHal", "", status);
+    }
     _hidl_cb(retval, speakerAngles);
     return Void();
 }
 
-Return<Result> VirtualizerEffect::forceVirtualizationMode(AudioDevice device) {
-    return mEffect->setParam(VIRTUALIZER_PARAM_FORCE_VIRTUALIZATION_MODE,
-                             static_cast<audio_devices_t>(device));
-}
-
 Return<void> VirtualizerEffect::getVirtualizationMode(getVirtualizationMode_cb _hidl_cb) {
     uint32_t halMode = 0;
     Result retval = mEffect->getParam(VIRTUALIZER_PARAM_FORCE_VIRTUALIZATION_MODE, halMode);
+#if MAJOR_VERSION <= 6
     _hidl_cb(retval, AudioDevice(halMode));
+#else
+    DeviceAddress device;
+    (void)HidlUtils::deviceAddressFromHal(static_cast<audio_devices_t>(halMode), nullptr, &device);
+    _hidl_cb(retval, device);
+#endif
     return Void();
 }
 
+Return<Result> VirtualizerEffect::forceVirtualizationMode(
+#if MAJOR_VERSION <= 6
+        AudioDevice device) {
+    audio_devices_t halDeviceType = static_cast<audio_devices_t>(device);
+#else
+        const DeviceAddress& device) {
+    audio_devices_t halDeviceType;
+    char halDeviceAddress[AUDIO_DEVICE_MAX_ADDRESS_LEN];
+    (void)HidlUtils::deviceAddressToHal(device, &halDeviceType, halDeviceAddress);
+#endif
+    return mEffect->setParam(VIRTUALIZER_PARAM_FORCE_VIRTUALIZATION_MODE, halDeviceType);
+}
+
+#if MAJOR_VERSION <= 6
+// static
+status_t VirtualizerEffect::speakerAnglesFromHal(const int32_t* halAngles, uint32_t channelCount,
+                                                 hidl_vec<SpeakerAngle>& speakerAngles) {
+    speakerAngles.resize(channelCount);
+    for (uint32_t i = 0; i < channelCount; ++i) {
+        speakerAngles[i].mask = AudioChannelBitfield(*halAngles++);
+        speakerAngles[i].azimuth = *halAngles++;
+        speakerAngles[i].elevation = *halAngles++;
+    }
+    return NO_ERROR;
+}
+#else
+static int compare_channels(const void* lhs, const void* rhs) {
+    return *(int32_t*)lhs - *(int32_t*)rhs;
+}
+
+// static
+status_t VirtualizerEffect::speakerAnglesFromHal(const int32_t* halAngles, uint32_t channelCount,
+                                                 SpeakerAngles& speakerAngles) {
+    speakerAngles.azimuth.resize(channelCount);
+    speakerAngles.elevation.resize(channelCount);
+    int32_t halAnglesSorted[channelCount * 3];
+    memcpy(halAnglesSorted, halAngles, sizeof(halAnglesSorted));
+    // Ensure that channels are ordered from LSb to MSb.
+    qsort(halAnglesSorted, channelCount, sizeof(int32_t) * 3, compare_channels);
+    audio_channel_mask_t halMask = AUDIO_CHANNEL_NONE;
+    int32_t* halAnglesPtr = halAnglesSorted;
+    for (uint32_t i = 0; i < channelCount; ++i) {
+        halMask = static_cast<audio_channel_mask_t>(halMask | *halAnglesPtr++);
+        speakerAngles.azimuth[i] = *halAnglesPtr++;
+        speakerAngles.elevation[i] = *halAnglesPtr++;
+    }
+    return HidlUtils::audioChannelMaskFromHal(halMask, false /*isInput*/, &speakerAngles.mask);
+}
+#endif
+
 }  // namespace implementation
 }  // namespace CPP_VERSION
 }  // namespace effect
diff --git a/audio/effect/all-versions/default/VirtualizerEffect.h b/audio/effect/all-versions/default/VirtualizerEffect.h
index c630b2e..3ed06d1 100644
--- a/audio/effect/all-versions/default/VirtualizerEffect.h
+++ b/audio/effect/all-versions/default/VirtualizerEffect.h
@@ -39,7 +39,9 @@
 using ::android::hardware::hidl_vec;
 using ::android::hardware::Return;
 using ::android::hardware::Void;
+#if MAJOR_VERSION <= 6
 using ::android::hardware::audio::common::CPP_VERSION::implementation::AudioChannelBitfield;
+#endif
 using namespace ::android::hardware::audio::common::CPP_VERSION;
 using namespace ::android::hardware::audio::effect::CPP_VERSION;
 
@@ -54,7 +56,15 @@
     Return<Result> reset() override;
     Return<Result> enable() override;
     Return<Result> disable() override;
+#if MAJOR_VERSION <= 6
+    Return<Result> setAudioSource(AudioSource source) override;
     Return<Result> setDevice(AudioDeviceBitfield device) override;
+    Return<Result> setInputDevice(AudioDeviceBitfield device) override;
+#else
+    Return<Result> setAudioSource(const AudioSource& source) override;
+    Return<Result> setDevice(const DeviceAddress& device) override;
+    Return<Result> setInputDevice(const DeviceAddress& device) override;
+#endif
     Return<void> setAndGetVolume(const hidl_vec<uint32_t>& volumes,
                                  setAndGetVolume_cb _hidl_cb) override;
     Return<Result> volumeChangeNotification(const hidl_vec<uint32_t>& volumes) override;
@@ -62,14 +72,12 @@
     Return<Result> setConfigReverse(
         const EffectConfig& config, const sp<IEffectBufferProviderCallback>& inputBufferProvider,
         const sp<IEffectBufferProviderCallback>& outputBufferProvider) override;
-    Return<Result> setInputDevice(AudioDeviceBitfield device) override;
     Return<void> getConfig(getConfig_cb _hidl_cb) override;
     Return<void> getConfigReverse(getConfigReverse_cb _hidl_cb) override;
     Return<void> getSupportedAuxChannelsConfigs(
         uint32_t maxConfigs, getSupportedAuxChannelsConfigs_cb _hidl_cb) override;
     Return<void> getAuxChannelsConfig(getAuxChannelsConfig_cb _hidl_cb) override;
     Return<Result> setAuxChannelsConfig(const EffectAuxChannelsConfig& config) override;
-    Return<Result> setAudioSource(AudioSource source) override;
     Return<Result> offload(const EffectOffloadParameter& param) override;
     Return<void> getDescriptor(getDescriptor_cb _hidl_cb) override;
     Return<void> prepareForProcessing(prepareForProcessing_cb _hidl_cb) override;
@@ -96,18 +104,27 @@
     Return<bool> isStrengthSupported() override;
     Return<Result> setStrength(uint16_t strength) override;
     Return<void> getStrength(getStrength_cb _hidl_cb) override;
+    Return<void> getVirtualizationMode(getVirtualizationMode_cb _hidl_cb) override;
+#if MAJOR_VERSION <= 6
     Return<void> getVirtualSpeakerAngles(AudioChannelBitfield mask, AudioDevice device,
                                          getVirtualSpeakerAngles_cb _hidl_cb) override;
     Return<Result> forceVirtualizationMode(AudioDevice device) override;
-    Return<void> getVirtualizationMode(getVirtualizationMode_cb _hidl_cb) override;
+#else
+    Return<void> getVirtualSpeakerAngles(const AudioChannelMask& mask, const DeviceAddress& device,
+                                         getVirtualSpeakerAngles_cb _hidl_cb) override;
+    Return<Result> forceVirtualizationMode(const DeviceAddress& device) override;
+#endif
 
-   private:
+  private:
     sp<Effect> mEffect;
 
-    virtual ~VirtualizerEffect();
+    virtual ~VirtualizerEffect() = default;
 
-    void speakerAnglesFromHal(const int32_t* halAngles, uint32_t channelCount,
-                              hidl_vec<SpeakerAngle>& speakerAngles);
+#if MAJOR_VERSION <= 6
+    using SpeakerAngles = hidl_vec<SpeakerAngle>;
+#endif
+    static status_t speakerAnglesFromHal(const int32_t* halAngles, uint32_t channelCount,
+                                         SpeakerAngles& speakerAngles);
 };
 
 }  // namespace implementation
diff --git a/audio/effect/all-versions/default/VisualizerEffect.cpp b/audio/effect/all-versions/default/VisualizerEffect.cpp
index ae533bf..80c8637 100644
--- a/audio/effect/all-versions/default/VisualizerEffect.cpp
+++ b/audio/effect/all-versions/default/VisualizerEffect.cpp
@@ -31,9 +31,9 @@
 namespace implementation {
 
 VisualizerEffect::VisualizerEffect(effect_handle_t handle)
-    : mEffect(new Effect(handle)), mCaptureSize(0), mMeasurementMode(MeasurementMode::NONE) {}
-
-VisualizerEffect::~VisualizerEffect() {}
+    : mEffect(new Effect(false /*isInput*/, handle)),
+      mCaptureSize(0),
+      mMeasurementMode(MeasurementMode::NONE) {}
 
 // Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffect follow.
 Return<Result> VisualizerEffect::init() {
@@ -58,10 +58,32 @@
     return mEffect->disable();
 }
 
+#if MAJOR_VERSION <= 6
+Return<Result> VisualizerEffect::setAudioSource(AudioSource source) {
+    return mEffect->setAudioSource(source);
+}
+
 Return<Result> VisualizerEffect::setDevice(AudioDeviceBitfield device) {
     return mEffect->setDevice(device);
 }
 
+Return<Result> VisualizerEffect::setInputDevice(AudioDeviceBitfield device) {
+    return mEffect->setInputDevice(device);
+}
+#else
+Return<Result> VisualizerEffect::setAudioSource(const AudioSource& source) {
+    return mEffect->setAudioSource(source);
+}
+
+Return<Result> VisualizerEffect::setDevice(const DeviceAddress& device) {
+    return mEffect->setDevice(device);
+}
+
+Return<Result> VisualizerEffect::setInputDevice(const DeviceAddress& device) {
+    return mEffect->setInputDevice(device);
+}
+#endif
+
 Return<void> VisualizerEffect::setAndGetVolume(const hidl_vec<uint32_t>& volumes,
                                                setAndGetVolume_cb _hidl_cb) {
     return mEffect->setAndGetVolume(volumes, _hidl_cb);
@@ -81,10 +103,6 @@
     return mEffect->setConfigReverse(config, inputBufferProvider, outputBufferProvider);
 }
 
-Return<Result> VisualizerEffect::setInputDevice(AudioDeviceBitfield device) {
-    return mEffect->setInputDevice(device);
-}
-
 Return<void> VisualizerEffect::getConfig(getConfig_cb _hidl_cb) {
     return mEffect->getConfig(_hidl_cb);
 }
@@ -106,10 +124,6 @@
     return mEffect->setAuxChannelsConfig(config);
 }
 
-Return<Result> VisualizerEffect::setAudioSource(AudioSource source) {
-    return mEffect->setAudioSource(source);
-}
-
 Return<Result> VisualizerEffect::offload(const EffectOffloadParameter& param) {
     return mEffect->offload(param);
 }
diff --git a/audio/effect/all-versions/default/VisualizerEffect.h b/audio/effect/all-versions/default/VisualizerEffect.h
index 315f844..3ae4b08 100644
--- a/audio/effect/all-versions/default/VisualizerEffect.h
+++ b/audio/effect/all-versions/default/VisualizerEffect.h
@@ -53,7 +53,15 @@
     Return<Result> reset() override;
     Return<Result> enable() override;
     Return<Result> disable() override;
+#if MAJOR_VERSION <= 6
+    Return<Result> setAudioSource(AudioSource source) override;
     Return<Result> setDevice(AudioDeviceBitfield device) override;
+    Return<Result> setInputDevice(AudioDeviceBitfield device) override;
+#else
+    Return<Result> setAudioSource(const AudioSource& source) override;
+    Return<Result> setDevice(const DeviceAddress& device) override;
+    Return<Result> setInputDevice(const DeviceAddress& device) override;
+#endif
     Return<void> setAndGetVolume(const hidl_vec<uint32_t>& volumes,
                                  setAndGetVolume_cb _hidl_cb) override;
     Return<Result> volumeChangeNotification(const hidl_vec<uint32_t>& volumes) override;
@@ -61,14 +69,12 @@
     Return<Result> setConfigReverse(
         const EffectConfig& config, const sp<IEffectBufferProviderCallback>& inputBufferProvider,
         const sp<IEffectBufferProviderCallback>& outputBufferProvider) override;
-    Return<Result> setInputDevice(AudioDeviceBitfield device) override;
     Return<void> getConfig(getConfig_cb _hidl_cb) override;
     Return<void> getConfigReverse(getConfigReverse_cb _hidl_cb) override;
     Return<void> getSupportedAuxChannelsConfigs(
         uint32_t maxConfigs, getSupportedAuxChannelsConfigs_cb _hidl_cb) override;
     Return<void> getAuxChannelsConfig(getAuxChannelsConfig_cb _hidl_cb) override;
     Return<Result> setAuxChannelsConfig(const EffectAuxChannelsConfig& config) override;
-    Return<Result> setAudioSource(AudioSource source) override;
     Return<Result> offload(const EffectOffloadParameter& param) override;
     Return<void> getDescriptor(getDescriptor_cb _hidl_cb) override;
     Return<void> prepareForProcessing(prepareForProcessing_cb _hidl_cb) override;
@@ -107,7 +113,7 @@
     uint16_t mCaptureSize;
     MeasurementMode mMeasurementMode;
 
-    virtual ~VisualizerEffect();
+    virtual ~VisualizerEffect() = default;
 };
 
 }  // namespace implementation
diff --git a/audio/effect/all-versions/vts/functional/VtsHalAudioEffectTargetTest.cpp b/audio/effect/all-versions/vts/functional/VtsHalAudioEffectTargetTest.cpp
index 199a8a5..d39fbcd 100644
--- a/audio/effect/all-versions/vts/functional/VtsHalAudioEffectTargetTest.cpp
+++ b/audio/effect/all-versions/vts/functional/VtsHalAudioEffectTargetTest.cpp
@@ -263,7 +263,7 @@
         static_cast<audio_channel_mask_t>(currentConfig.outputCfg.channels));
 #else
     *channelCount = android::audio::policy::configuration::V7_0::getChannelCount(
-            currentConfig.outputCfg.channels);
+            currentConfig.outputCfg.base.channelMask);
     ASSERT_NE(*channelCount, 0);
 #endif
 }
@@ -353,8 +353,14 @@
 }
 
 inline bool operator==(const EffectBufferConfig& lhs, const EffectBufferConfig& rhs) {
-    return lhs.buffer == rhs.buffer && lhs.samplingRateHz == rhs.samplingRateHz &&
-           lhs.channels == rhs.channels && lhs.format == rhs.format &&
+    return lhs.buffer == rhs.buffer &&
+#if MAJOR_VERSION <= 6
+           lhs.samplingRateHz == rhs.samplingRateHz && lhs.channels == rhs.channels &&
+           lhs.format == rhs.format &&
+#else
+           lhs.base.sampleRateHz == rhs.base.sampleRateHz &&
+           lhs.base.channelMask == rhs.base.channelMask && lhs.base.format == rhs.base.format &&
+#endif
            lhs.accessMode == rhs.accessMode && lhs.mask == rhs.mask;
 }
 
diff --git a/automotive/audiocontrol/aidl/android/hardware/automotive/audiocontrol/AudioFocusChange.aidl b/automotive/audiocontrol/aidl/android/hardware/automotive/audiocontrol/AudioFocusChange.aidl
index fc35fa9..98fa4e8 100644
--- a/automotive/audiocontrol/aidl/android/hardware/automotive/audiocontrol/AudioFocusChange.aidl
+++ b/automotive/audiocontrol/aidl/android/hardware/automotive/audiocontrol/AudioFocusChange.aidl
@@ -27,7 +27,7 @@
     GAIN_TRANSIENT = 2,
     GAIN_TRANSIENT_MAY_DUCK = 3,
     GAIN_TRANSIENT_EXCLUSIVE = 4,
-    LOSS = -1, // -1 * GAIN,
-    LOSS_TRANSIENT = -2, // -1 * GAIN_TRANSIENT,
-    LOSS_TRANSIENT_CAN_DUCK = -3, // -1 * GAIN_TRANSIENT_MAY_DUCK,
+    LOSS = -1 * GAIN,
+    LOSS_TRANSIENT = -1 * GAIN_TRANSIENT,
+    LOSS_TRANSIENT_CAN_DUCK = -1 * GAIN_TRANSIENT_MAY_DUCK,
 }
\ No newline at end of file
diff --git a/automotive/can/1.0/default/libnl++/Android.bp b/automotive/can/1.0/default/libnl++/Android.bp
index 4042b16..90e1002 100644
--- a/automotive/can/1.0/default/libnl++/Android.bp
+++ b/automotive/can/1.0/default/libnl++/Android.bp
@@ -25,6 +25,7 @@
         "protocols/generic/Generic.cpp",
         "protocols/generic/GenericMessageBase.cpp",
         "protocols/generic/Unknown.cpp",
+        "protocols/generic/families/Nl80211.cpp",
         "protocols/route/Link.cpp",
         "protocols/route/Route.cpp",
         "protocols/route/structs.cpp",
diff --git a/automotive/can/1.0/default/libnl++/printer.cpp b/automotive/can/1.0/default/libnl++/printer.cpp
index e6cada2..f08897e 100644
--- a/automotive/can/1.0/default/libnl++/printer.cpp
+++ b/automotive/can/1.0/default/libnl++/printer.cpp
@@ -51,24 +51,24 @@
     printFlag(NLM_F_DUMP_FILTERED, "DUMP_FILTERED");
 
     switch (genre) {
-        case protocols::MessageGenre::UNKNOWN:
+        case protocols::MessageGenre::Unknown:
             break;
-        case protocols::MessageGenre::GET:
+        case protocols::MessageGenre::Get:
             printFlag(NLM_F_DUMP, "DUMP");  // ROOT | MATCH
             printFlag(NLM_F_ROOT, "ROOT");
             printFlag(NLM_F_MATCH, "MATCH");
             printFlag(NLM_F_ATOMIC, "ATOMIC");
             break;
-        case protocols::MessageGenre::NEW:
+        case protocols::MessageGenre::New:
             printFlag(NLM_F_REPLACE, "REPLACE");
             printFlag(NLM_F_EXCL, "EXCL");
             printFlag(NLM_F_CREATE, "CREATE");
             printFlag(NLM_F_APPEND, "APPEND");
             break;
-        case protocols::MessageGenre::DELETE:
+        case protocols::MessageGenre::Delete:
             printFlag(NLM_F_NONREC, "NONREC");
             break;
-        case protocols::MessageGenre::ACK:
+        case protocols::MessageGenre::Ack:
             printFlag(NLM_F_CAPPED, "CAPPED");
             printFlag(NLM_F_ACK_TLVS, "ACK_TLVS");
             break;
@@ -99,11 +99,25 @@
 static void toStream(std::stringstream& ss, const Buffer<nlattr> attr,
                      const protocols::AttributeMap& attrMap) {
     using DataType = protocols::AttributeDefinition::DataType;
+    using Flags = protocols::AttributeDefinition::Flags;
     const auto attrtype = attrMap[attr->nla_type];
 
-    ss << attrtype.name << ": ";
+    ss << attrtype.name;
+
+    if (attrtype.dataType == DataType::Flag && attr.data<uint8_t>().getRaw().len() == 0) return;
+    ss << ": ";
+
+    if (attrtype.flags == Flags::Verbose) {
+        const auto raw = attr.data<uint8_t>();
+        ss << "{len=" << raw.getRaw().len();
+        ss << ", crc=" << std::hex << std::setw(4) << crc16(raw) << std::dec;
+        ss << "}";
+        return;
+    }
+
     switch (attrtype.dataType) {
         case DataType::Raw:
+        case DataType::Flag:
             toStream(ss, attr.data<uint8_t>());
             break;
         case DataType::Nested: {
@@ -117,13 +131,19 @@
             ss << '}';
             break;
         }
+        case DataType::StringNul:
         case DataType::String: {
             const auto str = attr.data<char>().getRaw();
-            ss << '"' << printableOnly({str.ptr(), str.len()}) << '"';
+            auto len = str.len();
+            if (attrtype.dataType == DataType::StringNul && len > 0 && str.ptr()[len - 1] == '\0') {
+                len--;
+            }
+
+            ss << '"' << printableOnly({str.ptr(), len}) << '"';
             break;
         }
         case DataType::Uint:
-            ss << attr.data<uint32_t>().copyFirst();
+            ss << attr.data<uint64_t>().copyFirst();
             break;
         case DataType::Struct: {
             const auto structToStream =
@@ -147,10 +167,12 @@
     }
     protocols::NetlinkProtocol& protocolDescr = *protocolMaybe;
 
-    const auto msgDescMaybe = protocolDescr.getMessageDescriptor(hdr->nlmsg_type);
+    auto msgDescMaybe = protocolDescr.getMessageDescriptor(hdr->nlmsg_type);
     const auto msgDetails =
             protocols::MessageDescriptor::getMessageDetails(msgDescMaybe, hdr->nlmsg_type);
 
+    if (msgDescMaybe.has_value()) msgDescMaybe->get().track(hdr);
+
     ss << "nlmsg{" << protocolDescr.getName() << " ";
 
     ss << "hdr={";
diff --git a/automotive/can/1.0/default/libnl++/protocols/MessageDefinition.cpp b/automotive/can/1.0/default/libnl++/protocols/MessageDefinition.cpp
index c93d865..aaf24a5 100644
--- a/automotive/can/1.0/default/libnl++/protocols/MessageDefinition.cpp
+++ b/automotive/can/1.0/default/libnl++/protocols/MessageDefinition.cpp
@@ -56,15 +56,17 @@
 
 MessageDescriptor::MessageDetails MessageDescriptor::getMessageDetails(nlmsgtype_t msgtype) const {
     const auto it = mMessageDetails.find(msgtype);
-    if (it == mMessageDetails.end()) return {std::to_string(msgtype), MessageGenre::UNKNOWN};
+    if (it == mMessageDetails.end()) return {std::to_string(msgtype), MessageGenre::Unknown};
     return it->second;
 }
 
 MessageDescriptor::MessageDetails MessageDescriptor::getMessageDetails(
-        const std::optional<std::reference_wrapper<const MessageDescriptor>>& msgDescMaybe,
+        const std::optional<std::reference_wrapper<MessageDescriptor>>& msgDescMaybe,
         nlmsgtype_t msgtype) {
     if (msgDescMaybe.has_value()) return msgDescMaybe->get().getMessageDetails(msgtype);
-    return {std::to_string(msgtype), protocols::MessageGenre::UNKNOWN};
+    return {std::to_string(msgtype), protocols::MessageGenre::Unknown};
 }
 
+void MessageDescriptor::track(const Buffer<nlmsghdr> /* hdr */) {}
+
 }  // namespace android::nl::protocols
diff --git a/automotive/can/1.0/default/libnl++/protocols/MessageDefinition.h b/automotive/can/1.0/default/libnl++/protocols/MessageDefinition.h
index bd0e60f..8bed5e7 100644
--- a/automotive/can/1.0/default/libnl++/protocols/MessageDefinition.h
+++ b/automotive/can/1.0/default/libnl++/protocols/MessageDefinition.h
@@ -54,17 +54,64 @@
  */
 struct AttributeDefinition {
     enum class DataType : uint8_t {
+        /**
+         * Binary blob (or attribute of unknown type).
+         */
         Raw,
+
+        /**
+         * Nested attribute (with or without NLA_F_NESTED).
+         */
         Nested,
+
+        /**
+         * Non-null terminated string.
+         *
+         * The length of the string is determined by the size of an attribute.
+         */
         String,
+
+        /**
+         * Null terminated string.
+         */
+        StringNul,
+
+        /**
+         * Unsigned integer of size 8, 16, 32 or 64 bits.
+         */
         Uint,
+
+        /**
+         * Structure which printer is defined in ops ToStream variant.
+         */
         Struct,
+
+        /**
+         * Flag attribute.
+         *
+         * The attribute doesn't have any contents. The flag is set when the attribute is present,
+         * it's not when it's absent from attribute list.
+         */
+        Flag,
+    };
+    enum class Flags : uint8_t {
+        Verbose = (1 << 0),
     };
     using ToStream = std::function<void(std::stringstream& ss, const Buffer<nlattr> attr)>;
 
     std::string name;
     DataType dataType = DataType::Raw;
     std::variant<AttributeMap, ToStream> ops = AttributeMap{};
+
+    /**
+     * Attribute flags.
+     *
+     * It's not really a bitmask flag set (since you are not supposed to compare enum class by
+     * bitmask), but std::set<Flags> bumps compile time from 16s to 3m. Let's leave it as-is for
+     * now and revisit if we get some flags that can be used in pairs. When it happens, review all
+     * uses of the flags field to include the "&" operator and not "==".
+     */
+    Flags flags = {};
 };
 
 /**
@@ -74,11 +121,11 @@
  * section in linux/netlink.h.
  */
 enum class MessageGenre {
-    UNKNOWN,
-    GET,
-    NEW,
-    DELETE,
-    ACK,
+    Unknown,
+    Get,
+    New,
+    Delete,
+    Ack,
 };
 
 /**
@@ -103,8 +150,15 @@
     MessageDetails getMessageDetails(nlmsgtype_t msgtype) const;
     virtual void dataToStream(std::stringstream& ss, const Buffer<nlmsghdr> hdr) const = 0;
 
+    /**
+     * Message tracking for stateful protocols (such as NETLINK_GENERIC).
+     *
+     * \param hdr Message to track
+     */
+    virtual void track(const Buffer<nlmsghdr> hdr);
+
     static MessageDetails getMessageDetails(
-            const std::optional<std::reference_wrapper<const MessageDescriptor>>& msgDescMaybe,
+            const std::optional<std::reference_wrapper<MessageDescriptor>>& msgDescMaybe,
             nlmsgtype_t msgtype);
 
   protected:
diff --git a/automotive/can/1.0/default/libnl++/protocols/NetlinkProtocol.cpp b/automotive/can/1.0/default/libnl++/protocols/NetlinkProtocol.cpp
index cd2e8c6..16208ab 100644
--- a/automotive/can/1.0/default/libnl++/protocols/NetlinkProtocol.cpp
+++ b/automotive/can/1.0/default/libnl++/protocols/NetlinkProtocol.cpp
@@ -32,7 +32,7 @@
     return mName;
 }
 
-const std::optional<std::reference_wrapper<const MessageDescriptor>>
+const std::optional<std::reference_wrapper<MessageDescriptor>>
 NetlinkProtocol::getMessageDescriptor(nlmsgtype_t nlmsg_type) {
     if (mMessageDescrs.count(nlmsg_type) == 0) return std::nullopt;
     return *mMessageDescrs.find(nlmsg_type)->second;
@@ -41,7 +41,7 @@
 NetlinkProtocol::MessageDescriptorMap NetlinkProtocol::toMap(
         const NetlinkProtocol::MessageDescriptorList& descrs, int protocol) {
     MessageDescriptorMap map;
-    for (const auto& descr : descrs) {
+    for (auto& descr : descrs) {
         for (const auto& [mtype, mdet] : descr->getMessageDetailsMap()) {
             map.emplace(mtype, descr);
         }
diff --git a/automotive/can/1.0/default/libnl++/protocols/NetlinkProtocol.h b/automotive/can/1.0/default/libnl++/protocols/NetlinkProtocol.h
index c969547..b173b91 100644
--- a/automotive/can/1.0/default/libnl++/protocols/NetlinkProtocol.h
+++ b/automotive/can/1.0/default/libnl++/protocols/NetlinkProtocol.h
@@ -40,17 +40,17 @@
 
     const std::string& getName() const;
 
-    virtual const std::optional<std::reference_wrapper<const MessageDescriptor>>
-    getMessageDescriptor(nlmsgtype_t nlmsg_type);
+    virtual const std::optional<std::reference_wrapper<MessageDescriptor>> getMessageDescriptor(
+            nlmsgtype_t nlmsg_type);
 
   protected:
-    typedef std::vector<std::shared_ptr<const MessageDescriptor>> MessageDescriptorList;
+    typedef std::vector<std::shared_ptr<MessageDescriptor>> MessageDescriptorList;
 
     NetlinkProtocol(int protocol, const std::string& name,
                     const MessageDescriptorList&& messageDescrs);
 
   private:
-    typedef std::map<nlmsgtype_t, std::shared_ptr<const MessageDescriptor>> MessageDescriptorMap;
+    typedef std::map<nlmsgtype_t, std::shared_ptr<MessageDescriptor>> MessageDescriptorMap;
 
     const int mProtocol;
     const std::string mName;
diff --git a/automotive/can/1.0/default/libnl++/protocols/common/Empty.cpp b/automotive/can/1.0/default/libnl++/protocols/common/Empty.cpp
index 8a672d3..4b509c9 100644
--- a/automotive/can/1.0/default/libnl++/protocols/common/Empty.cpp
+++ b/automotive/can/1.0/default/libnl++/protocols/common/Empty.cpp
@@ -20,9 +20,9 @@
 
 // clang-format off
 Empty::Empty() : MessageDefinition<char>("nlmsg", {
-    {NLMSG_NOOP, {"NOOP", MessageGenre::UNKNOWN}},
-    {NLMSG_DONE, {"DONE", MessageGenre::UNKNOWN}},
-    {NLMSG_OVERRUN, {"OVERRUN", MessageGenre::UNKNOWN}},
+    {NLMSG_NOOP, {"NOOP", MessageGenre::Unknown}},
+    {NLMSG_DONE, {"DONE", MessageGenre::Unknown}},
+    {NLMSG_OVERRUN, {"OVERRUN", MessageGenre::Unknown}},
 }) {}
 // clang-format on
 
diff --git a/automotive/can/1.0/default/libnl++/protocols/common/Error.cpp b/automotive/can/1.0/default/libnl++/protocols/common/Error.cpp
index 44708a3..77451ed 100644
--- a/automotive/can/1.0/default/libnl++/protocols/common/Error.cpp
+++ b/automotive/can/1.0/default/libnl++/protocols/common/Error.cpp
@@ -20,13 +20,15 @@
 
 #include <libnl++/printer.h>
 
+#include <map>
+
 namespace android::nl::protocols::base {
 
 using DataType = AttributeDefinition::DataType;
 
 // clang-format off
 Error::Error(int protocol) : MessageDefinition<nlmsgerr>("nlmsg", {
-    {NLMSG_ERROR, {"ERROR", MessageGenre::ACK}},
+    {NLMSG_ERROR, {"ERROR", MessageGenre::Ack}},
 }, {
     {NLMSGERR_ATTR_MSG, {"MSG", DataType::String}},
     {NLMSGERR_ATTR_OFFS, {"OFFS", DataType::Uint}},
@@ -34,9 +36,156 @@
 }), mProtocol(protocol) {}
 // clang-format on
 
+std::map<int, std::string> errnoNames{
+        {EPERM, "EPERM"},                      // Operation not permitted
+        {ENOENT, "ENOENT"},                    // No such file or directory
+        {ESRCH, "ESRCH"},                      // No such process
+        {EINTR, "EINTR"},                      // Interrupted system call
+        {EIO, "EIO"},                          // I/O error
+        {ENXIO, "ENXIO"},                      // No such device or address
+        {E2BIG, "E2BIG"},                      // Argument list too long
+        {ENOEXEC, "ENOEXEC"},                  // Exec format error
+        {EBADF, "EBADF"},                      // Bad file number
+        {ECHILD, "ECHILD"},                    // No child processes
+        {EAGAIN, "EAGAIN"},                    // Try again
+        {ENOMEM, "ENOMEM"},                    // Out of memory
+        {EACCES, "EACCES"},                    // Permission denied
+        {EFAULT, "EFAULT"},                    // Bad address
+        {ENOTBLK, "ENOTBLK"},                  // Block device required
+        {EBUSY, "EBUSY"},                      // Device or resource busy
+        {EEXIST, "EEXIST"},                    // File exists
+        {EXDEV, "EXDEV"},                      // Cross-device link
+        {ENODEV, "ENODEV"},                    // No such device
+        {ENOTDIR, "ENOTDIR"},                  // Not a directory
+        {EISDIR, "EISDIR"},                    // Is a directory
+        {EINVAL, "EINVAL"},                    // Invalid argument
+        {ENFILE, "ENFILE"},                    // File table overflow
+        {EMFILE, "EMFILE"},                    // Too many open files
+        {ENOTTY, "ENOTTY"},                    // Not a typewriter
+        {ETXTBSY, "ETXTBSY"},                  // Text file busy
+        {EFBIG, "EFBIG"},                      // File too large
+        {ENOSPC, "ENOSPC"},                    // No space left on device
+        {ESPIPE, "ESPIPE"},                    // Illegal seek
+        {EROFS, "EROFS"},                      // Read-only file system
+        {EMLINK, "EMLINK"},                    // Too many links
+        {EPIPE, "EPIPE"},                      // Broken pipe
+        {EDOM, "EDOM"},                        // Math argument out of domain of func
+        {ERANGE, "ERANGE"},                    // Math result not representable
+        {EDEADLK, "EDEADLK"},                  // Resource deadlock would occur
+        {ENAMETOOLONG, "ENAMETOOLONG"},        // File name too long
+        {ENOLCK, "ENOLCK"},                    // No record locks available
+        {ENOSYS, "ENOSYS"},                    // Invalid system call number
+        {ENOTEMPTY, "ENOTEMPTY"},              // Directory not empty
+        {ELOOP, "ELOOP"},                      // Too many symbolic links encountered
+        {ENOMSG, "ENOMSG"},                    // No message of desired type
+        {EIDRM, "EIDRM"},                      // Identifier removed
+        {ECHRNG, "ECHRNG"},                    // Channel number out of range
+        {EL2NSYNC, "EL2NSYNC"},                // Level 2 not synchronized
+        {EL3HLT, "EL3HLT"},                    // Level 3 halted
+        {EL3RST, "EL3RST"},                    // Level 3 reset
+        {ELNRNG, "ELNRNG"},                    // Link number out of range
+        {EUNATCH, "EUNATCH"},                  // Protocol driver not attached
+        {ENOCSI, "ENOCSI"},                    // No CSI structure available
+        {EL2HLT, "EL2HLT"},                    // Level 2 halted
+        {EBADE, "EBADE"},                      // Invalid exchange
+        {EBADR, "EBADR"},                      // Invalid request descriptor
+        {EXFULL, "EXFULL"},                    // Exchange full
+        {ENOANO, "ENOANO"},                    // No anode
+        {EBADRQC, "EBADRQC"},                  // Invalid request code
+        {EBADSLT, "EBADSLT"},                  // Invalid slot
+        {EBFONT, "EBFONT"},                    // Bad font file format
+        {ENOSTR, "ENOSTR"},                    // Device not a stream
+        {ENODATA, "ENODATA"},                  // No data available
+        {ETIME, "ETIME"},                      // Timer expired
+        {ENOSR, "ENOSR"},                      // Out of streams resources
+        {ENONET, "ENONET"},                    // Machine is not on the network
+        {ENOPKG, "ENOPKG"},                    // Package not installed
+        {EREMOTE, "EREMOTE"},                  // Object is remote
+        {ENOLINK, "ENOLINK"},                  // Link has been severed
+        {EADV, "EADV"},                        // Advertise error
+        {ESRMNT, "ESRMNT"},                    // Srmount error
+        {ECOMM, "ECOMM"},                      // Communication error on send
+        {EPROTO, "EPROTO"},                    // Protocol error
+        {EMULTIHOP, "EMULTIHOP"},              // Multihop attempted
+        {EDOTDOT, "EDOTDOT"},                  // RFS specific error
+        {EBADMSG, "EBADMSG"},                  // Not a data message
+        {EOVERFLOW, "EOVERFLOW"},              // Value too large for defined data type
+        {ENOTUNIQ, "ENOTUNIQ"},                // Name not unique on network
+        {EBADFD, "EBADFD"},                    // File descriptor in bad state
+        {EREMCHG, "EREMCHG"},                  // Remote address changed
+        {ELIBACC, "ELIBACC"},                  // Can not access a needed shared library
+        {ELIBBAD, "ELIBBAD"},                  // Accessing a corrupted shared library
+        {ELIBSCN, "ELIBSCN"},                  // .lib section in a.out corrupted
+        {ELIBMAX, "ELIBMAX"},                  // Attempting to link in too many shared libraries
+        {ELIBEXEC, "ELIBEXEC"},                // Cannot exec a shared library directly
+        {EILSEQ, "EILSEQ"},                    // Illegal byte sequence
+        {ERESTART, "ERESTART"},                // Interrupted system call should be restarted
+        {ESTRPIPE, "ESTRPIPE"},                // Streams pipe error
+        {EUSERS, "EUSERS"},                    // Too many users
+        {ENOTSOCK, "ENOTSOCK"},                // Socket operation on non-socket
+        {EDESTADDRREQ, "EDESTADDRREQ"},        // Destination address required
+        {EMSGSIZE, "EMSGSIZE"},                // Message too long
+        {EPROTOTYPE, "EPROTOTYPE"},            // Protocol wrong type for socket
+        {ENOPROTOOPT, "ENOPROTOOPT"},          // Protocol not available
+        {EPROTONOSUPPORT, "EPROTONOSUPPORT"},  // Protocol not supported
+        {ESOCKTNOSUPPORT, "ESOCKTNOSUPPORT"},  // Socket type not supported
+        {EOPNOTSUPP, "EOPNOTSUPP"},            // Operation not supported on transport endpoint
+        {EPFNOSUPPORT, "EPFNOSUPPORT"},        // Protocol family not supported
+        {EAFNOSUPPORT, "EAFNOSUPPORT"},        // Address family not supported by protocol
+        {EADDRINUSE, "EADDRINUSE"},            // Address already in use
+        {EADDRNOTAVAIL, "EADDRNOTAVAIL"},      // Cannot assign requested address
+        {ENETDOWN, "ENETDOWN"},                // Network is down
+        {ENETUNREACH, "ENETUNREACH"},          // Network is unreachable
+        {ENETRESET, "ENETRESET"},              // Network dropped connection because of reset
+        {ECONNABORTED, "ECONNABORTED"},        // Software caused connection abort
+        {ECONNRESET, "ECONNRESET"},            // Connection reset by peer
+        {ENOBUFS, "ENOBUFS"},                  // No buffer space available
+        {EISCONN, "EISCONN"},                  // Transport endpoint is already connected
+        {ENOTCONN, "ENOTCONN"},                // Transport endpoint is not connected
+        {ESHUTDOWN, "ESHUTDOWN"},              // Cannot send after transport endpoint shutdown
+        {ETOOMANYREFS, "ETOOMANYREFS"},        // Too many references: cannot splice
+        {ETIMEDOUT, "ETIMEDOUT"},              // Connection timed out
+        {ECONNREFUSED, "ECONNREFUSED"},        // Connection refused
+        {EHOSTDOWN, "EHOSTDOWN"},              // Host is down
+        {EHOSTUNREACH, "EHOSTUNREACH"},        // No route to host
+        {EALREADY, "EALREADY"},                // Operation already in progress
+        {EINPROGRESS, "EINPROGRESS"},          // Operation now in progress
+        {ESTALE, "ESTALE"},                    // Stale file handle
+        {EUCLEAN, "EUCLEAN"},                  // Structure needs cleaning
+        {ENOTNAM, "ENOTNAM"},                  // Not a XENIX named type file
+        {ENAVAIL, "ENAVAIL"},                  // No XENIX semaphores available
+        {EISNAM, "EISNAM"},                    // Is a named type file
+        {EREMOTEIO, "EREMOTEIO"},              // Remote I/O error
+        {EDQUOT, "EDQUOT"},                    // Quota exceeded
+        {ENOMEDIUM, "ENOMEDIUM"},              // No medium found
+        {EMEDIUMTYPE, "EMEDIUMTYPE"},          // Wrong medium type
+        {ECANCELED, "ECANCELED"},              // Operation Canceled
+        {ENOKEY, "ENOKEY"},                    // Required key not available
+        {EKEYEXPIRED, "EKEYEXPIRED"},          // Key has expired
+        {EKEYREVOKED, "EKEYREVOKED"},          // Key has been revoked
+        {EKEYREJECTED, "EKEYREJECTED"},        // Key was rejected by service
+        {EOWNERDEAD, "EOWNERDEAD"},            // Owner died
+        {ENOTRECOVERABLE, "ENOTRECOVERABLE"},  // State not recoverable
+        {ERFKILL, "ERFKILL"},                  // Operation not possible due to RF-kill
+        {EHWPOISON, "EHWPOISON"},              // Memory page has hardware error
+
+        // Duplicates: EWOULDBLOCK (Operation would block), EDEADLOCK
+};
+
 void Error::toStream(std::stringstream& ss, const nlmsgerr& data) const {
-    ss << "nlmsgerr{error=" << data.error
-       << ", msg=" << toString({&data.msg, sizeof(data.msg)}, mProtocol, false) << "}";
+    ss << "nlmsgerr{";
+    if (data.error == 0) {
+        ss << "ACK";
+    } else {
+        ss << "error=";
+        const auto nameIt = errnoNames.find(-data.error);
+        if (nameIt == errnoNames.end()) {
+            ss << data.error;
+        } else {
+            ss << nameIt->second;
+        }
+    }
+    ss << ", msg=" << toString({&data.msg, sizeof(data.msg)}, mProtocol, false) << "}";
 }
 
 }  // namespace android::nl::protocols::base
diff --git a/automotive/can/1.0/default/libnl++/protocols/generic/Ctrl.cpp b/automotive/can/1.0/default/libnl++/protocols/generic/Ctrl.cpp
index a3c6736..1e1ad12 100644
--- a/automotive/can/1.0/default/libnl++/protocols/generic/Ctrl.cpp
+++ b/automotive/can/1.0/default/libnl++/protocols/generic/Ctrl.cpp
@@ -16,12 +16,19 @@
 
 #include "Ctrl.h"
 
+#include "families/Nl80211.h"
+
+#include <libnl++/Message.h>
+
 namespace android::nl::protocols::generic {
 
 using DataType = AttributeDefinition::DataType;
+using Flags = AttributeDefinition::Flags;
 
 // clang-format off
-Ctrl::Ctrl() : GenericMessageBase(GENL_ID_CTRL, "ID_CTRL", {
+Ctrl::Ctrl(Generic::FamilyRegister& familyRegister)
+    : GenericMessageBase(GENL_ID_CTRL, "ID_CTRL",
+{
     {CTRL_CMD_NEWFAMILY, "NEWFAMILY"},
     {CTRL_CMD_DELFAMILY, "DELFAMILY"},
     {CTRL_CMD_GETFAMILY, "GETFAMILY"},
@@ -33,7 +40,7 @@
     {CTRL_CMD_GETMCAST_GRP, "GETMCAST_GRP"},
 }, {
     {CTRL_ATTR_FAMILY_ID, {"FAMILY_ID", DataType::Uint}},
-    {CTRL_ATTR_FAMILY_NAME, {"FAMILY_NAME", DataType::String}},
+    {CTRL_ATTR_FAMILY_NAME, {"FAMILY_NAME", DataType::StringNul}},
     {CTRL_ATTR_VERSION, {"VERSION", DataType::Uint}},
     {CTRL_ATTR_HDRSIZE, {"HDRSIZE", DataType::Uint}},
     {CTRL_ATTR_MAXATTR, {"MAXATTR", DataType::Uint}},
@@ -42,14 +49,31 @@
             {CTRL_ATTR_OP_ID, {"ID", DataType::Uint}},
             {CTRL_ATTR_OP_FLAGS, {"FLAGS", DataType::Uint}},
         }}},
-    }}},
+    }, Flags::Verbose}},
     {CTRL_ATTR_MCAST_GROUPS, {"MCAST_GROUPS", DataType::Nested, AttributeMap{
         {std::nullopt, {"GRP", DataType::Nested, AttributeMap{
-            {CTRL_ATTR_MCAST_GRP_NAME, {"NAME", DataType::String}},
+            {CTRL_ATTR_MCAST_GRP_NAME, {"NAME", DataType::StringNul}},
             {CTRL_ATTR_MCAST_GRP_ID, {"ID", DataType::Uint}},
         }}},
     }}},
-}) {}
+}), mFamilyRegister(familyRegister) {}
 // clang-format on
 
+void Ctrl::track(const Buffer<nlmsghdr> hdr) {
+    const auto msgMaybe = Message<genlmsghdr>::parse(hdr, {GENL_ID_CTRL});
+    if (!msgMaybe.has_value()) return;
+    const auto msg = *msgMaybe;
+
+    if (msg->cmd != CTRL_CMD_NEWFAMILY) return;
+    const auto familyId = msg.attributes.get<uint16_t>(CTRL_ATTR_FAMILY_ID);
+    const auto familyName = msg.attributes.get<std::string>(CTRL_ATTR_FAMILY_NAME);
+
+    /* For now, we support just a single family. But if you add more, please define proper
+     * abstraction and not hardcode every name and class here.
+     */
+    if (familyName == "nl80211") {
+        mFamilyRegister[familyId] = std::make_shared<families::Nl80211>(familyId);
+    }
+}
+
 }  // namespace android::nl::protocols::generic
diff --git a/automotive/can/1.0/default/libnl++/protocols/generic/Ctrl.h b/automotive/can/1.0/default/libnl++/protocols/generic/Ctrl.h
index 6af87a8..b13df02 100644
--- a/automotive/can/1.0/default/libnl++/protocols/generic/Ctrl.h
+++ b/automotive/can/1.0/default/libnl++/protocols/generic/Ctrl.h
@@ -16,13 +16,19 @@
 
 #pragma once
 
+#include "Generic.h"
 #include "GenericMessageBase.h"
 
 namespace android::nl::protocols::generic {
 
 class Ctrl : public GenericMessageBase {
   public:
-    Ctrl();
+    Ctrl(Generic::FamilyRegister& familyRegister);
+
+    void track(const Buffer<nlmsghdr> hdr) override;
+
+  private:
+    Generic::FamilyRegister& mFamilyRegister;
 };
 
 }  // namespace android::nl::protocols::generic
diff --git a/automotive/can/1.0/default/libnl++/protocols/generic/Generic.cpp b/automotive/can/1.0/default/libnl++/protocols/generic/Generic.cpp
index 1a24914..5e34a1f 100644
--- a/automotive/can/1.0/default/libnl++/protocols/generic/Generic.cpp
+++ b/automotive/can/1.0/default/libnl++/protocols/generic/Generic.cpp
@@ -21,11 +21,12 @@
 
 namespace android::nl::protocols::generic {
 
-Generic::Generic() : NetlinkProtocol(NETLINK_GENERIC, "GENERIC", {std::make_shared<Ctrl>()}) {}
+Generic::Generic()
+    : NetlinkProtocol(NETLINK_GENERIC, "GENERIC", {std::make_shared<Ctrl>(mFamilyRegister)}) {}
 
-const std::optional<std::reference_wrapper<const MessageDescriptor>> Generic::getMessageDescriptor(
+const std::optional<std::reference_wrapper<MessageDescriptor>> Generic::getMessageDescriptor(
         nlmsgtype_t nlmsg_type) {
-    const auto desc = NetlinkProtocol::getMessageDescriptor(nlmsg_type);
+    auto desc = NetlinkProtocol::getMessageDescriptor(nlmsg_type);
     if (desc.has_value()) return desc;
 
     auto it = mFamilyRegister.find(nlmsg_type);
diff --git a/automotive/can/1.0/default/libnl++/protocols/generic/Generic.h b/automotive/can/1.0/default/libnl++/protocols/generic/Generic.h
index 593c92d..2cdd584 100644
--- a/automotive/can/1.0/default/libnl++/protocols/generic/Generic.h
+++ b/automotive/can/1.0/default/libnl++/protocols/generic/Generic.h
@@ -25,13 +25,15 @@
  */
 class Generic : public NetlinkProtocol {
   public:
+    typedef std::map<nlmsgtype_t, std::shared_ptr<MessageDescriptor>> FamilyRegister;
+
     Generic();
 
-    const std::optional<std::reference_wrapper<const MessageDescriptor>> getMessageDescriptor(
+    const std::optional<std::reference_wrapper<MessageDescriptor>> getMessageDescriptor(
             nlmsgtype_t nlmsg_type);
 
   private:
-    std::map<nlmsgtype_t, std::shared_ptr<const MessageDescriptor>> mFamilyRegister;
+    FamilyRegister mFamilyRegister;
 };
 
 }  // namespace android::nl::protocols::generic
diff --git a/automotive/can/1.0/default/libnl++/protocols/generic/GenericMessageBase.cpp b/automotive/can/1.0/default/libnl++/protocols/generic/GenericMessageBase.cpp
index 134638e..b7b811b 100644
--- a/automotive/can/1.0/default/libnl++/protocols/generic/GenericMessageBase.cpp
+++ b/automotive/can/1.0/default/libnl++/protocols/generic/GenericMessageBase.cpp
@@ -22,16 +22,27 @@
         nlmsgtype_t msgtype, const std::string&& msgname,
         const std::initializer_list<GenericCommandNameMap::value_type> commandNames,
         const std::initializer_list<AttributeMap::value_type> attrTypes)
-    : MessageDefinition<genlmsghdr>(msgname, {{msgtype, {msgname, MessageGenre::UNKNOWN}}},
+    : MessageDefinition<genlmsghdr>(msgname, {{msgtype, {msgname, MessageGenre::Unknown}}},
                                     attrTypes),
       mCommandNames(commandNames) {}
 
 void GenericMessageBase::toStream(std::stringstream& ss, const genlmsghdr& data) const {
+    const auto commandNameIt = mCommandNames.find(data.cmd);
+    const auto commandName = (commandNameIt == mCommandNames.end())
+                                     ? std::nullopt
+                                     : std::optional<std::string>(commandNameIt->second);
+
+    if (commandName.has_value() && data.version == 1 && data.reserved == 0) {
+        // short version
+        ss << *commandName;
+        return;
+    }
+
     ss << "genlmsghdr{";
-    if (mCommandNames.count(data.cmd) == 0) {
+    if (commandName.has_value()) {
         ss << "cmd=" << unsigned(data.cmd);
     } else {
-        ss << "cmd=" << mCommandNames.find(data.cmd)->second;
+        ss << "cmd=" << *commandName;
     }
     ss << ", version=" << unsigned(data.version);
     if (data.reserved != 0) ss << ", reserved=" << data.reserved;
diff --git a/automotive/can/1.0/default/libnl++/protocols/generic/families/Nl80211.cpp b/automotive/can/1.0/default/libnl++/protocols/generic/families/Nl80211.cpp
new file mode 100644
index 0000000..23ec66f
--- /dev/null
+++ b/automotive/can/1.0/default/libnl++/protocols/generic/families/Nl80211.cpp
@@ -0,0 +1,1009 @@
+/*
+ * 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 "Nl80211.h"
+
+#include "../../structs.h"
+#include "common.h"
+
+#include <linux/nl80211.h>
+
+#include <iomanip>
+
+namespace android::nl::protocols::generic::families {
+
+/**
+ * Reduce verbosity of printed Information Elements.
+ */
+static constexpr bool kCompactIE = true;
+
+enum {
+    // broken compatibility in Aug 2020
+    NL80211_ATTR_CNTDWN_OFFS_BEACON = NL80211_ATTR_CSA_C_OFF_BEACON,
+    NL80211_ATTR_CNTDWN_OFFS_PRESP = NL80211_ATTR_CSA_C_OFF_PRESP,
+
+    // new fields not available in current Android
+    NL80211_ATTR_FILS_DISCOVERY = NL80211_ATTR_HE_6GHZ_CAPABILITY + 1,
+    NL80211_ATTR_UNSOL_BCAST_PROBE_RESP,
+    NL80211_ATTR_S1G_CAPABILITY,
+    NL80211_ATTR_S1G_CAPABILITY_MASK,
+
+    NL80211_FREQUENCY_ATTR_1MHZ = NL80211_FREQUENCY_ATTR_OFFSET + 1,
+    NL80211_FREQUENCY_ATTR_2MHZ,
+    NL80211_FREQUENCY_ATTR_4MHZ,
+    NL80211_FREQUENCY_ATTR_8MHZ,
+    NL80211_FREQUENCY_ATTR_16MHZ,
+};
+
+enum ieee80211_eid {
+    WLAN_EID_SSID = 0,
+};
+
+using DataType = AttributeDefinition::DataType;
+using Flags = AttributeDefinition::Flags;
+
+static void informationElementsToStream(std::stringstream& ss, const Buffer<nlattr> attr);
+static void nl80211_pattern_supportToStream(std::stringstream& ss, const Buffer<nlattr> attr);
+
+static const AttributeMap iftypes{
+        {NL80211_IFTYPE_UNSPECIFIED, {"UNSPECIFIED", DataType::Flag}},
+        {NL80211_IFTYPE_ADHOC, {"ADHOC", DataType::Flag}},
+        {NL80211_IFTYPE_STATION, {"STATION", DataType::Flag}},
+        {NL80211_IFTYPE_AP, {"AP", DataType::Flag}},
+        {NL80211_IFTYPE_AP_VLAN, {"AP_VLAN", DataType::Flag}},
+        {NL80211_IFTYPE_WDS, {"WDS", DataType::Flag}},
+        {NL80211_IFTYPE_MONITOR, {"MONITOR", DataType::Flag}},
+        {NL80211_IFTYPE_MESH_POINT, {"MESH_POINT", DataType::Flag}},
+        {NL80211_IFTYPE_P2P_CLIENT, {"P2P_CLIENT", DataType::Flag}},
+        {NL80211_IFTYPE_P2P_GO, {"P2P_GO", DataType::Flag}},
+        {NL80211_IFTYPE_P2P_DEVICE, {"P2P_DEVICE", DataType::Flag}},
+        {NL80211_IFTYPE_OCB, {"OCB", DataType::Flag}},
+        {NL80211_IFTYPE_NAN, {"NAN", DataType::Flag}},
+};
+
+// clang-format off
+Nl80211::Nl80211(nlmsgtype_t familyId) : GenericMessageBase(familyId, "nl80211", {
+    /* Script to generate the (initial) top-level list from linux/nl80211.h:
+     * sed -e 's/^  NL80211_CMD_\(.*\),$/    {NL80211_CMD_\1, "\1"},/g'
+     */
+    {NL80211_CMD_UNSPEC, "UNSPEC"},
+
+    {NL80211_CMD_GET_WIPHY, "GET_WIPHY"},
+    {NL80211_CMD_SET_WIPHY, "SET_WIPHY"},
+    {NL80211_CMD_NEW_WIPHY, "NEW_WIPHY"},
+    {NL80211_CMD_DEL_WIPHY, "DEL_WIPHY"},
+
+    {NL80211_CMD_GET_INTERFACE, "GET_INTERFACE"},
+    {NL80211_CMD_SET_INTERFACE, "SET_INTERFACE"},
+    {NL80211_CMD_NEW_INTERFACE, "NEW_INTERFACE"},
+    {NL80211_CMD_DEL_INTERFACE, "DEL_INTERFACE"},
+
+    {NL80211_CMD_GET_KEY, "GET_KEY"},
+    {NL80211_CMD_SET_KEY, "SET_KEY"},
+    {NL80211_CMD_NEW_KEY, "NEW_KEY"},
+    {NL80211_CMD_DEL_KEY, "DEL_KEY"},
+
+    {NL80211_CMD_GET_BEACON, "GET_BEACON"},
+    {NL80211_CMD_SET_BEACON, "SET_BEACON"},
+    {NL80211_CMD_START_AP, "START_AP"},
+    {NL80211_CMD_STOP_AP, "STOP_AP"},
+
+    {NL80211_CMD_GET_STATION, "GET_STATION"},
+    {NL80211_CMD_SET_STATION, "SET_STATION"},
+    {NL80211_CMD_NEW_STATION, "NEW_STATION"},
+    {NL80211_CMD_DEL_STATION, "DEL_STATION"},
+
+    {NL80211_CMD_GET_MPATH, "GET_MPATH"},
+    {NL80211_CMD_SET_MPATH, "SET_MPATH"},
+    {NL80211_CMD_NEW_MPATH, "NEW_MPATH"},
+    {NL80211_CMD_DEL_MPATH, "DEL_MPATH"},
+
+    {NL80211_CMD_SET_BSS, "SET_BSS"},
+
+    {NL80211_CMD_SET_REG, "SET_REG"},
+    {NL80211_CMD_REQ_SET_REG, "REQ_SET_REG"},
+
+    {NL80211_CMD_GET_MESH_CONFIG, "GET_MESH_CONFIG"},
+    {NL80211_CMD_SET_MESH_CONFIG, "SET_MESH_CONFIG"},
+
+    {NL80211_CMD_SET_MGMT_EXTRA_IE, "SET_MGMT_EXTRA_IE"},
+
+    {NL80211_CMD_GET_REG, "GET_REG"},
+
+    {NL80211_CMD_GET_SCAN, "GET_SCAN"},
+    {NL80211_CMD_TRIGGER_SCAN, "TRIGGER_SCAN"},
+    {NL80211_CMD_NEW_SCAN_RESULTS, "NEW_SCAN_RESULTS"},
+    {NL80211_CMD_SCAN_ABORTED, "SCAN_ABORTED"},
+
+    {NL80211_CMD_REG_CHANGE, "REG_CHANGE"},
+
+    {NL80211_CMD_AUTHENTICATE, "AUTHENTICATE"},
+    {NL80211_CMD_ASSOCIATE, "ASSOCIATE"},
+    {NL80211_CMD_DEAUTHENTICATE, "DEAUTHENTICATE"},
+    {NL80211_CMD_DISASSOCIATE, "DISASSOCIATE"},
+
+    {NL80211_CMD_MICHAEL_MIC_FAILURE, "MICHAEL_MIC_FAILURE"},
+
+    {NL80211_CMD_REG_BEACON_HINT, "REG_BEACON_HINT"},
+
+    {NL80211_CMD_JOIN_IBSS, "JOIN_IBSS"},
+    {NL80211_CMD_LEAVE_IBSS, "LEAVE_IBSS"},
+
+    {NL80211_CMD_TESTMODE, "TESTMODE"},
+
+    {NL80211_CMD_CONNECT, "CONNECT"},
+    {NL80211_CMD_ROAM, "ROAM"},
+    {NL80211_CMD_DISCONNECT, "DISCONNECT"},
+
+    {NL80211_CMD_SET_WIPHY_NETNS, "SET_WIPHY_NETNS"},
+
+    {NL80211_CMD_GET_SURVEY, "GET_SURVEY"},
+    {NL80211_CMD_NEW_SURVEY_RESULTS, "NEW_SURVEY_RESULTS"},
+
+    {NL80211_CMD_SET_PMKSA, "SET_PMKSA"},
+    {NL80211_CMD_DEL_PMKSA, "DEL_PMKSA"},
+    {NL80211_CMD_FLUSH_PMKSA, "FLUSH_PMKSA"},
+
+    {NL80211_CMD_REMAIN_ON_CHANNEL, "REMAIN_ON_CHANNEL"},
+    {NL80211_CMD_CANCEL_REMAIN_ON_CHANNEL, "CANCEL_REMAIN_ON_CHANNEL"},
+
+    {NL80211_CMD_SET_TX_BITRATE_MASK, "SET_TX_BITRATE_MASK"},
+
+    {NL80211_CMD_REGISTER_FRAME, "REGISTER_FRAME"},
+    {NL80211_CMD_FRAME, "FRAME"},
+    {NL80211_CMD_FRAME_TX_STATUS, "FRAME_TX_STATUS"},
+
+    {NL80211_CMD_SET_POWER_SAVE, "SET_POWER_SAVE"},
+    {NL80211_CMD_GET_POWER_SAVE, "GET_POWER_SAVE"},
+
+    {NL80211_CMD_SET_CQM, "SET_CQM"},
+    {NL80211_CMD_NOTIFY_CQM, "NOTIFY_CQM"},
+
+    {NL80211_CMD_SET_CHANNEL, "SET_CHANNEL"},
+    {NL80211_CMD_SET_WDS_PEER, "SET_WDS_PEER"},
+
+    {NL80211_CMD_FRAME_WAIT_CANCEL, "FRAME_WAIT_CANCEL"},
+
+    {NL80211_CMD_JOIN_MESH, "JOIN_MESH"},
+    {NL80211_CMD_LEAVE_MESH, "LEAVE_MESH"},
+
+    {NL80211_CMD_UNPROT_DEAUTHENTICATE, "UNPROT_DEAUTHENTICATE"},
+    {NL80211_CMD_UNPROT_DISASSOCIATE, "UNPROT_DISASSOCIATE"},
+
+    {NL80211_CMD_NEW_PEER_CANDIDATE, "NEW_PEER_CANDIDATE"},
+
+    {NL80211_CMD_GET_WOWLAN, "GET_WOWLAN"},
+    {NL80211_CMD_SET_WOWLAN, "SET_WOWLAN"},
+
+    {NL80211_CMD_START_SCHED_SCAN, "START_SCHED_SCAN"},
+    {NL80211_CMD_STOP_SCHED_SCAN, "STOP_SCHED_SCAN"},
+    {NL80211_CMD_SCHED_SCAN_RESULTS, "SCHED_SCAN_RESULTS"},
+    {NL80211_CMD_SCHED_SCAN_STOPPED, "SCHED_SCAN_STOPPED"},
+
+    {NL80211_CMD_SET_REKEY_OFFLOAD, "SET_REKEY_OFFLOAD"},
+
+    {NL80211_CMD_PMKSA_CANDIDATE, "PMKSA_CANDIDATE"},
+
+    {NL80211_CMD_TDLS_OPER, "TDLS_OPER"},
+    {NL80211_CMD_TDLS_MGMT, "TDLS_MGMT"},
+
+    {NL80211_CMD_UNEXPECTED_FRAME, "UNEXPECTED_FRAME"},
+
+    {NL80211_CMD_PROBE_CLIENT, "PROBE_CLIENT"},
+
+    {NL80211_CMD_REGISTER_BEACONS, "REGISTER_BEACONS"},
+
+    {NL80211_CMD_UNEXPECTED_4ADDR_FRAME, "UNEXPECTED_4ADDR_FRAME"},
+
+    {NL80211_CMD_SET_NOACK_MAP, "SET_NOACK_MAP"},
+
+    {NL80211_CMD_CH_SWITCH_NOTIFY, "CH_SWITCH_NOTIFY"},
+
+    {NL80211_CMD_START_P2P_DEVICE, "START_P2P_DEVICE"},
+    {NL80211_CMD_STOP_P2P_DEVICE, "STOP_P2P_DEVICE"},
+
+    {NL80211_CMD_CONN_FAILED, "CONN_FAILED"},
+
+    {NL80211_CMD_SET_MCAST_RATE, "SET_MCAST_RATE"},
+
+    {NL80211_CMD_SET_MAC_ACL, "SET_MAC_ACL"},
+
+    {NL80211_CMD_RADAR_DETECT, "RADAR_DETECT"},
+
+    {NL80211_CMD_GET_PROTOCOL_FEATURES, "GET_PROTOCOL_FEATURES"},
+
+    {NL80211_CMD_UPDATE_FT_IES, "UPDATE_FT_IES"},
+    {NL80211_CMD_FT_EVENT, "FT_EVENT"},
+
+    {NL80211_CMD_CRIT_PROTOCOL_START, "CRIT_PROTOCOL_START"},
+    {NL80211_CMD_CRIT_PROTOCOL_STOP, "CRIT_PROTOCOL_STOP"},
+
+    {NL80211_CMD_GET_COALESCE, "GET_COALESCE"},
+    {NL80211_CMD_SET_COALESCE, "SET_COALESCE"},
+
+    {NL80211_CMD_CHANNEL_SWITCH, "CHANNEL_SWITCH"},
+
+    {NL80211_CMD_VENDOR, "VENDOR"},
+
+    {NL80211_CMD_SET_QOS_MAP, "SET_QOS_MAP"},
+
+    {NL80211_CMD_ADD_TX_TS, "ADD_TX_TS"},
+    {NL80211_CMD_DEL_TX_TS, "DEL_TX_TS"},
+
+    {NL80211_CMD_GET_MPP, "GET_MPP"},
+
+    {NL80211_CMD_JOIN_OCB, "JOIN_OCB"},
+    {NL80211_CMD_LEAVE_OCB, "LEAVE_OCB"},
+
+    {NL80211_CMD_CH_SWITCH_STARTED_NOTIFY, "CH_SWITCH_STARTED_NOTIFY"},
+
+    {NL80211_CMD_TDLS_CHANNEL_SWITCH, "TDLS_CHANNEL_SWITCH"},
+    {NL80211_CMD_TDLS_CANCEL_CHANNEL_SWITCH, "TDLS_CANCEL_CHANNEL_SWITCH"},
+
+    {NL80211_CMD_WIPHY_REG_CHANGE, "WIPHY_REG_CHANGE"},
+
+    {NL80211_CMD_ABORT_SCAN, "ABORT_SCAN"},
+
+    {NL80211_CMD_START_NAN, "START_NAN"},
+    {NL80211_CMD_STOP_NAN, "STOP_NAN"},
+    {NL80211_CMD_ADD_NAN_FUNCTION, "ADD_NAN_FUNCTION"},
+    {NL80211_CMD_DEL_NAN_FUNCTION, "DEL_NAN_FUNCTION"},
+    {NL80211_CMD_CHANGE_NAN_CONFIG, "CHANGE_NAN_CONFIG"},
+    {NL80211_CMD_NAN_MATCH, "NAN_MATCH"},
+
+    {NL80211_CMD_SET_MULTICAST_TO_UNICAST, "SET_MULTICAST_TO_UNICAST"},
+
+    {NL80211_CMD_UPDATE_CONNECT_PARAMS, "UPDATE_CONNECT_PARAMS"},
+
+    {NL80211_CMD_SET_PMK, "SET_PMK"},
+    {NL80211_CMD_DEL_PMK, "DEL_PMK"},
+
+    {NL80211_CMD_PORT_AUTHORIZED, "PORT_AUTHORIZED"},
+
+    {NL80211_CMD_RELOAD_REGDB, "RELOAD_REGDB"},
+
+    {NL80211_CMD_EXTERNAL_AUTH, "EXTERNAL_AUTH"},
+
+    {NL80211_CMD_STA_OPMODE_CHANGED, "STA_OPMODE_CHANGED"},
+
+    {NL80211_CMD_CONTROL_PORT_FRAME, "CONTROL_PORT_FRAME"},
+
+    {NL80211_CMD_GET_FTM_RESPONDER_STATS, "GET_FTM_RESPONDER_STATS"},
+
+    {NL80211_CMD_PEER_MEASUREMENT_START, "PEER_MEASUREMENT_START"},
+    {NL80211_CMD_PEER_MEASUREMENT_RESULT, "PEER_MEASUREMENT_RESULT"},
+    {NL80211_CMD_PEER_MEASUREMENT_COMPLETE, "PEER_MEASUREMENT_COMPLETE"},
+
+    {NL80211_CMD_NOTIFY_RADAR, "NOTIFY_RADAR"},
+
+    {NL80211_CMD_UPDATE_OWE_INFO, "UPDATE_OWE_INFO"},
+
+    {NL80211_CMD_PROBE_MESH_LINK, "PROBE_MESH_LINK"},
+
+    {NL80211_CMD_SET_TID_CONFIG, "SET_TID_CONFIG"},
+
+    {NL80211_CMD_UNPROT_BEACON, "UNPROT_BEACON"},
+
+    {NL80211_CMD_CONTROL_PORT_FRAME_TX_STATUS, "CONTROL_PORT_FRAME_TX_STATUS"},
+}, {
+    /* Script to generate the (initial) top-level list from linux/nl80211.h:
+     * sed -e 's/^\tNL80211_ATTR_\(.*\),$/    {NL80211_ATTR_\1, {"\1"}},/g'
+     */
+    {NL80211_ATTR_UNSPEC, {"UNSPEC"}},
+
+    {NL80211_ATTR_WIPHY, {"WIPHY", DataType::Uint}},
+    {NL80211_ATTR_WIPHY_NAME, {"WIPHY_NAME", DataType::StringNul}},
+
+    {NL80211_ATTR_IFINDEX, {"IFINDEX", DataType::Uint}},
+    {NL80211_ATTR_IFNAME, {"IFNAME", DataType::StringNul}},
+    {NL80211_ATTR_IFTYPE, {"IFTYPE", DataType::Uint}},
+
+    {NL80211_ATTR_MAC, {"MAC", DataType::Raw}},
+
+    {NL80211_ATTR_KEY_DATA, {"KEY_DATA"}},
+    {NL80211_ATTR_KEY_IDX, {"KEY_IDX"}},
+    {NL80211_ATTR_KEY_CIPHER, {"KEY_CIPHER"}},
+    {NL80211_ATTR_KEY_SEQ, {"KEY_SEQ"}},
+    {NL80211_ATTR_KEY_DEFAULT, {"KEY_DEFAULT"}},
+
+    {NL80211_ATTR_BEACON_INTERVAL, {"BEACON_INTERVAL"}},
+    {NL80211_ATTR_DTIM_PERIOD, {"DTIM_PERIOD"}},
+    {NL80211_ATTR_BEACON_HEAD, {"BEACON_HEAD"}},
+    {NL80211_ATTR_BEACON_TAIL, {"BEACON_TAIL"}},
+
+    {NL80211_ATTR_STA_AID, {"STA_AID"}},
+    {NL80211_ATTR_STA_FLAGS, {"STA_FLAGS"}},
+    {NL80211_ATTR_STA_LISTEN_INTERVAL, {"STA_LISTEN_INTERVAL"}},
+    {NL80211_ATTR_STA_SUPPORTED_RATES, {"STA_SUPPORTED_RATES"}},
+    {NL80211_ATTR_STA_VLAN, {"STA_VLAN"}},
+    {NL80211_ATTR_STA_INFO, {"STA_INFO"}},
+
+    {NL80211_ATTR_WIPHY_BANDS, {"WIPHY_BANDS", DataType::Nested, AttributeMap{
+        {std::nullopt, {"BAND", DataType::Nested, AttributeMap{
+            {NL80211_BAND_ATTR_FREQS, {"FREQS", DataType::Nested, AttributeMap{
+                {std::nullopt, {"FQ", DataType::Nested, AttributeMap{
+                    {NL80211_FREQUENCY_ATTR_FREQ, {"FREQ", DataType::Uint}},
+                    {NL80211_FREQUENCY_ATTR_DISABLED, {"DISABLED", DataType::Flag}},
+                    {NL80211_FREQUENCY_ATTR_NO_IR, {"NO_IR", DataType::Flag}},
+                    {__NL80211_FREQUENCY_ATTR_NO_IBSS, {"_NO_IBSS", DataType::Flag}},
+                    {NL80211_FREQUENCY_ATTR_RADAR, {"RADAR", DataType::Flag}},
+                    {NL80211_FREQUENCY_ATTR_MAX_TX_POWER, {"MAX_TX_POWER", DataType::Uint}},
+                    {NL80211_FREQUENCY_ATTR_DFS_STATE, {"DFS_STATE", DataType::Uint}},
+                    {NL80211_FREQUENCY_ATTR_DFS_TIME, {"DFS_TIME", DataType::Uint}},
+                    {NL80211_FREQUENCY_ATTR_NO_HT40_MINUS, {"NO_HT40_MINUS", DataType::Flag}},
+                    {NL80211_FREQUENCY_ATTR_NO_HT40_PLUS, {"NO_HT40_PLUS", DataType::Flag}},
+                    {NL80211_FREQUENCY_ATTR_NO_80MHZ, {"NO_80MHZ", DataType::Flag}},
+                    {NL80211_FREQUENCY_ATTR_NO_160MHZ, {"NO_160MHZ", DataType::Flag}},
+                    {NL80211_FREQUENCY_ATTR_DFS_CAC_TIME, {"DFS_CAC_TIME", DataType::Uint}},
+                    {NL80211_FREQUENCY_ATTR_INDOOR_ONLY, {"INDOOR_ONLY", DataType::Flag}},
+                    {NL80211_FREQUENCY_ATTR_IR_CONCURRENT, {"IR_CONCURRENT", DataType::Flag}},
+                    {NL80211_FREQUENCY_ATTR_NO_20MHZ, {"NO_20MHZ", DataType::Flag}},
+                    {NL80211_FREQUENCY_ATTR_NO_10MHZ, {"NO_10MHZ", DataType::Flag}},
+                    {NL80211_FREQUENCY_ATTR_WMM, {"WMM"}},
+                    {NL80211_FREQUENCY_ATTR_NO_HE, {"NO_HE", DataType::Flag}},
+                    {NL80211_FREQUENCY_ATTR_OFFSET, {"OFFSET", DataType::Uint}},
+                    {NL80211_FREQUENCY_ATTR_1MHZ, {"1MHZ", DataType::Flag}},
+                    {NL80211_FREQUENCY_ATTR_2MHZ, {"2MHZ", DataType::Flag}},
+                    {NL80211_FREQUENCY_ATTR_4MHZ, {"4MHZ", DataType::Flag}},
+                    {NL80211_FREQUENCY_ATTR_8MHZ, {"8MHZ", DataType::Flag}},
+                    {NL80211_FREQUENCY_ATTR_16MHZ, {"16MHZ", DataType::Flag}},
+                }}},
+            }, Flags::Verbose}},
+            {NL80211_BAND_ATTR_RATES, {"RATES", DataType::Nested, AttributeMap{
+                {std::nullopt, {"RATE", DataType::Nested, AttributeMap{
+                    {NL80211_BITRATE_ATTR_RATE, {"RATE", DataType::Uint}},
+                    {NL80211_BITRATE_ATTR_2GHZ_SHORTPREAMBLE,
+                            {"2GHZ_SHORTPREAMBLE", DataType::Flag}},
+                }}},
+            }}},
+
+            {NL80211_BAND_ATTR_HT_MCS_SET, {"HT_MCS_SET"}},  // struct ieee80211_mcs_info
+            {NL80211_BAND_ATTR_HT_CAPA, {"HT_CAPA", DataType::Uint}},
+            {NL80211_BAND_ATTR_HT_AMPDU_FACTOR, {"HT_AMPDU_FACTOR", DataType::Uint}},
+            {NL80211_BAND_ATTR_HT_AMPDU_DENSITY, {"HT_AMPDU_DENSITY", DataType::Uint}},
+
+            {NL80211_BAND_ATTR_VHT_MCS_SET, {"VHT_MCS_SET"}},  // struct ieee80211_vht_mcs_info
+            {NL80211_BAND_ATTR_VHT_CAPA, {"VHT_CAPA", DataType::Uint}},
+            {NL80211_BAND_ATTR_IFTYPE_DATA, {"IFTYPE_DATA"}},
+
+            {NL80211_BAND_ATTR_EDMG_CHANNELS, {"EDMG_CHANNELS"}},
+            {NL80211_BAND_ATTR_EDMG_BW_CONFIG, {"EDMG_BW_CONFIG"}},
+        }}},
+    }, Flags::Verbose}},
+
+    {NL80211_ATTR_MNTR_FLAGS, {"MNTR_FLAGS"}},
+
+    {NL80211_ATTR_MESH_ID, {"MESH_ID"}},
+    {NL80211_ATTR_STA_PLINK_ACTION, {"STA_PLINK_ACTION"}},
+    {NL80211_ATTR_MPATH_NEXT_HOP, {"MPATH_NEXT_HOP"}},
+    {NL80211_ATTR_MPATH_INFO, {"MPATH_INFO"}},
+
+    {NL80211_ATTR_BSS_CTS_PROT, {"BSS_CTS_PROT"}},
+    {NL80211_ATTR_BSS_SHORT_PREAMBLE, {"BSS_SHORT_PREAMBLE"}},
+    {NL80211_ATTR_BSS_SHORT_SLOT_TIME, {"BSS_SHORT_SLOT_TIME"}},
+
+    {NL80211_ATTR_HT_CAPABILITY, {"HT_CAPABILITY"}},
+
+    {NL80211_ATTR_SUPPORTED_IFTYPES, {"SUPPORTED_IFTYPES", DataType::Nested, iftypes}},
+
+    {NL80211_ATTR_REG_ALPHA2, {"REG_ALPHA2"}},
+    {NL80211_ATTR_REG_RULES, {"REG_RULES"}},
+
+    {NL80211_ATTR_MESH_CONFIG, {"MESH_CONFIG"}},
+
+    {NL80211_ATTR_BSS_BASIC_RATES, {"BSS_BASIC_RATES"}},
+
+    {NL80211_ATTR_WIPHY_TXQ_PARAMS, {"WIPHY_TXQ_PARAMS"}},
+    {NL80211_ATTR_WIPHY_FREQ, {"WIPHY_FREQ"}},
+    {NL80211_ATTR_WIPHY_CHANNEL_TYPE, {"WIPHY_CHANNEL_TYPE"}},
+
+    {NL80211_ATTR_KEY_DEFAULT_MGMT, {"KEY_DEFAULT_MGMT"}},
+
+    {NL80211_ATTR_MGMT_SUBTYPE, {"MGMT_SUBTYPE"}},
+    {NL80211_ATTR_IE, {"IE"}},
+
+    {NL80211_ATTR_MAX_NUM_SCAN_SSIDS, {"MAX_NUM_SCAN_SSIDS", DataType::Uint}},
+
+    {NL80211_ATTR_SCAN_FREQUENCIES, {"SCAN_FREQUENCIES", DataType::Nested, AttributeMap{
+        {std::nullopt, {"FQ", DataType::Uint}},
+    }, Flags::Verbose}},
+    {NL80211_ATTR_SCAN_SSIDS, {"SCAN_SSIDS", DataType::Nested, AttributeMap{
+        {std::nullopt, {"SSID", DataType::String}},
+    }}},
+    {NL80211_ATTR_GENERATION, {"GENERATION", DataType::Uint}},
+    {NL80211_ATTR_BSS, {"BSS", DataType::Nested, AttributeMap{
+        {NL80211_BSS_BSSID, {"BSSID", DataType::Raw}},
+        {NL80211_BSS_FREQUENCY, {"FREQUENCY", DataType::Uint}},
+        {NL80211_BSS_TSF, {"TSF", DataType::Uint}},
+        {NL80211_BSS_BEACON_INTERVAL, {"BEACON_INTERVAL", DataType::Uint}},
+        {NL80211_BSS_CAPABILITY, {"CAPABILITY", DataType::Uint}},
+        {NL80211_BSS_INFORMATION_ELEMENTS, {"INFORMATION_ELEMENTS",
+                DataType::Struct, informationElementsToStream}},
+        {NL80211_BSS_SIGNAL_MBM, {"SIGNAL_MBM", DataType::Uint}},
+        {NL80211_BSS_SIGNAL_UNSPEC, {"SIGNAL_UNSPEC", DataType::Uint}},
+        {NL80211_BSS_STATUS, {"STATUS", DataType::Uint}},  // enum nl80211_bss_status
+        {NL80211_BSS_SEEN_MS_AGO, {"SEEN_MS_AGO", DataType::Uint}},
+        {NL80211_BSS_BEACON_IES, {"BEACON_IES", DataType::Struct, informationElementsToStream}},
+        {NL80211_BSS_CHAN_WIDTH, {"CHAN_WIDTH", DataType::Uint}},
+        {NL80211_BSS_BEACON_TSF, {"BEACON_TSF", DataType::Uint}},
+        {NL80211_BSS_PRESP_DATA, {"PRESP_DATA", DataType::Flag}},
+        {NL80211_BSS_LAST_SEEN_BOOTTIME, {"LAST_SEEN_BOOTTIME", DataType::Uint}},
+        {NL80211_BSS_PAD, {"PAD"}},
+        {NL80211_BSS_PARENT_TSF, {"PARENT_TSF"}},
+        {NL80211_BSS_PARENT_BSSID, {"PARENT_BSSID"}},
+        {NL80211_BSS_CHAIN_SIGNAL, {"CHAIN_SIGNAL", DataType::Nested, AttributeMap{
+            {std::nullopt, {"SIG", DataType::Uint}},
+        }}},
+        {NL80211_BSS_FREQUENCY_OFFSET, {"FREQUENCY_OFFSET"}},
+    }}},
+
+    {NL80211_ATTR_REG_INITIATOR, {"REG_INITIATOR"}},
+    {NL80211_ATTR_REG_TYPE, {"REG_TYPE"}},
+
+    {NL80211_ATTR_SUPPORTED_COMMANDS, {"SUPPORTED_COMMANDS", DataType::Nested,AttributeMap{
+        {std::nullopt, {"CMD", DataType::Uint}}, // enum nl80211_commands
+    }}},
+
+    {NL80211_ATTR_FRAME, {"FRAME"}},
+    {NL80211_ATTR_SSID, {"SSID"}},
+    {NL80211_ATTR_AUTH_TYPE, {"AUTH_TYPE"}},
+    {NL80211_ATTR_REASON_CODE, {"REASON_CODE"}},
+
+    {NL80211_ATTR_KEY_TYPE, {"KEY_TYPE"}},
+
+    {NL80211_ATTR_MAX_SCAN_IE_LEN, {"MAX_SCAN_IE_LEN", DataType::Uint}},
+    {NL80211_ATTR_CIPHER_SUITES, {"CIPHER_SUITES", DataType::Struct, arrayToStream<int32_t>}},
+
+    {NL80211_ATTR_FREQ_BEFORE, {"FREQ_BEFORE"}},
+    {NL80211_ATTR_FREQ_AFTER, {"FREQ_AFTER"}},
+
+    {NL80211_ATTR_FREQ_FIXED, {"FREQ_FIXED"}},
+
+    {NL80211_ATTR_WIPHY_RETRY_SHORT, {"WIPHY_RETRY_SHORT", DataType::Uint}},
+    {NL80211_ATTR_WIPHY_RETRY_LONG, {"WIPHY_RETRY_LONG", DataType::Uint}},
+    {NL80211_ATTR_WIPHY_FRAG_THRESHOLD, {"WIPHY_FRAG_THRESHOLD", DataType::Uint}},
+    {NL80211_ATTR_WIPHY_RTS_THRESHOLD, {"WIPHY_RTS_THRESHOLD", DataType::Uint}},
+
+    {NL80211_ATTR_TIMED_OUT, {"TIMED_OUT"}},
+
+    {NL80211_ATTR_USE_MFP, {"USE_MFP"}},
+
+    {NL80211_ATTR_STA_FLAGS2, {"STA_FLAGS2"}},
+
+    {NL80211_ATTR_CONTROL_PORT, {"CONTROL_PORT"}},
+
+    {NL80211_ATTR_TESTDATA, {"TESTDATA"}},
+
+    {NL80211_ATTR_PRIVACY, {"PRIVACY"}},
+
+    {NL80211_ATTR_DISCONNECTED_BY_AP, {"DISCONNECTED_BY_AP"}},
+    {NL80211_ATTR_STATUS_CODE, {"STATUS_CODE"}},
+
+    {NL80211_ATTR_CIPHER_SUITES_PAIRWISE, {"CIPHER_SUITES_PAIRWISE"}},
+    {NL80211_ATTR_CIPHER_SUITE_GROUP, {"CIPHER_SUITE_GROUP"}},
+    {NL80211_ATTR_WPA_VERSIONS, {"WPA_VERSIONS"}},
+    {NL80211_ATTR_AKM_SUITES, {"AKM_SUITES"}},
+
+    {NL80211_ATTR_REQ_IE, {"REQ_IE"}},
+    {NL80211_ATTR_RESP_IE, {"RESP_IE"}},
+
+    {NL80211_ATTR_PREV_BSSID, {"PREV_BSSID"}},
+
+    {NL80211_ATTR_KEY, {"KEY"}},
+    {NL80211_ATTR_KEYS, {"KEYS"}},
+
+    {NL80211_ATTR_PID, {"PID"}},
+
+    {NL80211_ATTR_4ADDR, {"4ADDR"}},
+
+    {NL80211_ATTR_SURVEY_INFO, {"SURVEY_INFO"}},
+
+    {NL80211_ATTR_PMKID, {"PMKID"}},
+    {NL80211_ATTR_MAX_NUM_PMKIDS, {"MAX_NUM_PMKIDS", DataType::Uint}},
+
+    {NL80211_ATTR_DURATION, {"DURATION"}},
+
+    {NL80211_ATTR_COOKIE, {"COOKIE"}},
+
+    {NL80211_ATTR_WIPHY_COVERAGE_CLASS, {"WIPHY_COVERAGE_CLASS", DataType::Uint}},
+
+    {NL80211_ATTR_TX_RATES, {"TX_RATES"}},
+
+    {NL80211_ATTR_FRAME_MATCH, {"FRAME_MATCH"}},
+
+    {NL80211_ATTR_ACK, {"ACK"}},
+
+    {NL80211_ATTR_PS_STATE, {"PS_STATE"}},
+
+    {NL80211_ATTR_CQM, {"CQM"}},
+
+    {NL80211_ATTR_LOCAL_STATE_CHANGE, {"LOCAL_STATE_CHANGE"}},
+
+    {NL80211_ATTR_AP_ISOLATE, {"AP_ISOLATE"}},
+
+    {NL80211_ATTR_WIPHY_TX_POWER_SETTING, {"WIPHY_TX_POWER_SETTING"}},
+    {NL80211_ATTR_WIPHY_TX_POWER_LEVEL, {"WIPHY_TX_POWER_LEVEL"}},
+
+    {NL80211_ATTR_TX_FRAME_TYPES, {"TX_FRAME_TYPES", DataType::Nested, AttributeMap{
+        {std::nullopt, {"TFT", DataType::Nested, AttributeMap{
+            {NL80211_ATTR_FRAME_TYPE, {"FRAME_TYPE", DataType::Uint}},
+        }}},
+    }, Flags::Verbose}},
+    {NL80211_ATTR_RX_FRAME_TYPES, {"RX_FRAME_TYPES", DataType::Nested, AttributeMap{
+        {std::nullopt, {"RFT", DataType::Nested, AttributeMap{
+            {NL80211_ATTR_FRAME_TYPE, {"FRAME_TYPE", DataType::Uint}},
+        }}},
+    }, Flags::Verbose}},
+
+    {NL80211_ATTR_FRAME_TYPE, {"FRAME_TYPE", DataType::Uint}},
+
+    {NL80211_ATTR_CONTROL_PORT_ETHERTYPE, {"CONTROL_PORT_ETHERTYPE"}},
+    {NL80211_ATTR_CONTROL_PORT_NO_ENCRYPT, {"CONTROL_PORT_NO_ENCRYPT"}},
+
+    {NL80211_ATTR_SUPPORT_IBSS_RSN, {"SUPPORT_IBSS_RSN"}},
+
+    {NL80211_ATTR_WIPHY_ANTENNA_TX, {"WIPHY_ANTENNA_TX"}},
+    {NL80211_ATTR_WIPHY_ANTENNA_RX, {"WIPHY_ANTENNA_RX"}},
+
+    {NL80211_ATTR_MCAST_RATE, {"MCAST_RATE"}},
+
+    {NL80211_ATTR_OFFCHANNEL_TX_OK, {"OFFCHANNEL_TX_OK", DataType::Flag}},
+
+    {NL80211_ATTR_BSS_HT_OPMODE, {"BSS_HT_OPMODE"}},
+
+    {NL80211_ATTR_KEY_DEFAULT_TYPES, {"KEY_DEFAULT_TYPES"}},
+
+    {NL80211_ATTR_MAX_REMAIN_ON_CHANNEL_DURATION,
+            {"MAX_REMAIN_ON_CHANNEL_DURATION", DataType::Uint}},
+
+    {NL80211_ATTR_MESH_SETUP, {"MESH_SETUP"}},
+
+    {NL80211_ATTR_WIPHY_ANTENNA_AVAIL_TX, {"WIPHY_ANTENNA_AVAIL_TX", DataType::Uint}},
+    {NL80211_ATTR_WIPHY_ANTENNA_AVAIL_RX, {"WIPHY_ANTENNA_AVAIL_RX", DataType::Uint}},
+
+    {NL80211_ATTR_SUPPORT_MESH_AUTH, {"SUPPORT_MESH_AUTH"}},
+    {NL80211_ATTR_STA_PLINK_STATE, {"STA_PLINK_STATE"}},
+
+    {NL80211_ATTR_WOWLAN_TRIGGERS, {"WOWLAN_TRIGGERS"}},
+    {NL80211_ATTR_WOWLAN_TRIGGERS_SUPPORTED,
+            {"WOWLAN_TRIGGERS_SUPPORTED", DataType::Nested, AttributeMap{
+        {NL80211_WOWLAN_TRIG_ANY, {"ANY", DataType::Flag}},
+        {NL80211_WOWLAN_TRIG_DISCONNECT, {"DISCONNECT", DataType::Flag}},
+        {NL80211_WOWLAN_TRIG_MAGIC_PKT, {"MAGIC_PKT", DataType::Flag}},
+        {NL80211_WOWLAN_TRIG_PKT_PATTERN,
+                {"PKT_PATTERN", DataType::Struct, nl80211_pattern_supportToStream}},
+        {NL80211_WOWLAN_TRIG_GTK_REKEY_SUPPORTED, {"GTK_REKEY_SUPPORTED", DataType::Flag}},
+        {NL80211_WOWLAN_TRIG_GTK_REKEY_FAILURE, {"GTK_REKEY_FAILURE", DataType::Flag}},
+        {NL80211_WOWLAN_TRIG_EAP_IDENT_REQUEST, {"EAP_IDENT_REQUEST", DataType::Flag}},
+        {NL80211_WOWLAN_TRIG_4WAY_HANDSHAKE, {"4WAY_HANDSHAKE", DataType::Flag}},
+        {NL80211_WOWLAN_TRIG_RFKILL_RELEASE, {"RFKILL_RELEASE", DataType::Flag}},
+        {NL80211_WOWLAN_TRIG_TCP_CONNECTION, {"TCP_CONNECTION", DataType::Nested, AttributeMap{
+            {NL80211_WOWLAN_TCP_SRC_IPV4, {"SRC_IPV4"}},
+            {NL80211_WOWLAN_TCP_DST_IPV4, {"DST_IPV4"}},
+            {NL80211_WOWLAN_TCP_DST_MAC, {"DST_MAC"}},
+            {NL80211_WOWLAN_TCP_SRC_PORT, {"SRC_PORT", DataType::Uint}},
+            {NL80211_WOWLAN_TCP_DST_PORT, {"DST_PORT", DataType::Uint}},
+            {NL80211_WOWLAN_TCP_DATA_PAYLOAD, {"DATA_PAYLOAD"}},
+            {NL80211_WOWLAN_TCP_DATA_PAYLOAD_SEQ, {"DATA_PAYLOAD_SEQ"}},
+            {NL80211_WOWLAN_TCP_DATA_PAYLOAD_TOKEN, {"DATA_PAYLOAD_TOKEN"}},
+            {NL80211_WOWLAN_TCP_DATA_INTERVAL, {"DATA_INTERVAL", DataType::Uint}},
+            {NL80211_WOWLAN_TCP_WAKE_PAYLOAD, {"WAKE_PAYLOAD"}},
+            {NL80211_WOWLAN_TCP_WAKE_MASK, {"WAKE_MASK"}},
+        }}},
+        {NL80211_WOWLAN_TRIG_NET_DETECT, {"NET_DETECT", DataType::Uint}},
+
+        /* Not in WOWLAN_TRIGGERS_SUPPORTED:
+         * - NL80211_WOWLAN_TRIG_WAKEUP_PKT_80211
+         * - NL80211_WOWLAN_TRIG_WAKEUP_PKT_80211_LEN
+         * - NL80211_WOWLAN_TRIG_WAKEUP_PKT_8023
+         * - NL80211_WOWLAN_TRIG_WAKEUP_PKT_8023_LEN
+         * - NL80211_WOWLAN_TRIG_WAKEUP_TCP_MATCH
+         * - NL80211_WOWLAN_TRIG_WAKEUP_TCP_CONNLOST
+         * - NL80211_WOWLAN_TRIG_WAKEUP_TCP_NOMORETOKENS
+         * - NL80211_WOWLAN_TRIG_NET_DETECT_RESULTS
+         */
+    }}},
+
+    {NL80211_ATTR_SCHED_SCAN_INTERVAL, {"SCHED_SCAN_INTERVAL"}},
+
+    {NL80211_ATTR_INTERFACE_COMBINATIONS, {"INTERFACE_COMBINATIONS", DataType::Nested, AttributeMap{
+        {std::nullopt, {"IC", DataType::Nested, AttributeMap{
+            {NL80211_IFACE_COMB_UNSPEC, {"UNSPEC"}},
+            {NL80211_IFACE_COMB_LIMITS, {"LIMITS", DataType::Nested, AttributeMap{
+                {std::nullopt, {"LT", DataType::Nested, AttributeMap{
+                    {NL80211_IFACE_LIMIT_UNSPEC, {"UNSPEC"}},
+                    {NL80211_IFACE_LIMIT_MAX, {"MAX", DataType::Uint}},
+                    {NL80211_IFACE_LIMIT_TYPES, {"TYPES", DataType::Nested, iftypes}},
+                }}},
+            }}},
+            {NL80211_IFACE_COMB_MAXNUM, {"MAXNUM", DataType::Uint}},
+            {NL80211_IFACE_COMB_STA_AP_BI_MATCH, {"STA_AP_BI_MATCH", DataType::Flag}},
+            {NL80211_IFACE_COMB_NUM_CHANNELS, {"NUM_CHANNELS", DataType::Uint}},
+            {NL80211_IFACE_COMB_RADAR_DETECT_WIDTHS, {"RADAR_DETECT_WIDTHS", DataType::Uint}},
+            {NL80211_IFACE_COMB_RADAR_DETECT_REGIONS, {"RADAR_DETECT_REGIONS", DataType::Uint}},
+            {NL80211_IFACE_COMB_BI_MIN_GCD, {"BI_MIN_GCD"}},
+        }}},
+    }, Flags::Verbose}},
+    {NL80211_ATTR_SOFTWARE_IFTYPES, {"SOFTWARE_IFTYPES", DataType::Nested, iftypes}},
+
+    {NL80211_ATTR_REKEY_DATA, {"REKEY_DATA"}},
+
+    {NL80211_ATTR_MAX_NUM_SCHED_SCAN_SSIDS, {"MAX_NUM_SCHED_SCAN_SSIDS", DataType::Uint}},
+    {NL80211_ATTR_MAX_SCHED_SCAN_IE_LEN, {"MAX_SCHED_SCAN_IE_LEN", DataType::Uint}},
+
+    {NL80211_ATTR_SCAN_SUPP_RATES, {"SCAN_SUPP_RATES"}},
+
+    {NL80211_ATTR_HIDDEN_SSID, {"HIDDEN_SSID"}},
+
+    {NL80211_ATTR_IE_PROBE_RESP, {"IE_PROBE_RESP"}},
+    {NL80211_ATTR_IE_ASSOC_RESP, {"IE_ASSOC_RESP"}},
+
+    {NL80211_ATTR_STA_WME, {"STA_WME"}},
+    {NL80211_ATTR_SUPPORT_AP_UAPSD, {"SUPPORT_AP_UAPSD"}},
+
+    {NL80211_ATTR_ROAM_SUPPORT, {"ROAM_SUPPORT", DataType::Flag}},
+
+    {NL80211_ATTR_SCHED_SCAN_MATCH, {"SCHED_SCAN_MATCH"}},
+    {NL80211_ATTR_MAX_MATCH_SETS, {"MAX_MATCH_SETS", DataType::Uint}},
+
+    {NL80211_ATTR_PMKSA_CANDIDATE, {"PMKSA_CANDIDATE"}},
+
+    {NL80211_ATTR_TX_NO_CCK_RATE, {"TX_NO_CCK_RATE"}},
+
+    {NL80211_ATTR_TDLS_ACTION, {"TDLS_ACTION"}},
+    {NL80211_ATTR_TDLS_DIALOG_TOKEN, {"TDLS_DIALOG_TOKEN"}},
+    {NL80211_ATTR_TDLS_OPERATION, {"TDLS_OPERATION"}},
+    {NL80211_ATTR_TDLS_SUPPORT, {"TDLS_SUPPORT", DataType::Flag}},
+    {NL80211_ATTR_TDLS_EXTERNAL_SETUP, {"TDLS_EXTERNAL_SETUP", DataType::Flag}},
+
+    {NL80211_ATTR_DEVICE_AP_SME, {"DEVICE_AP_SME", DataType::Uint}},
+
+    {NL80211_ATTR_DONT_WAIT_FOR_ACK, {"DONT_WAIT_FOR_ACK"}},
+
+    {NL80211_ATTR_FEATURE_FLAGS, {"FEATURE_FLAGS", DataType::Uint}},
+
+    {NL80211_ATTR_PROBE_RESP_OFFLOAD, {"PROBE_RESP_OFFLOAD", DataType::Uint}},
+
+    {NL80211_ATTR_PROBE_RESP, {"PROBE_RESP"}},
+
+    {NL80211_ATTR_DFS_REGION, {"DFS_REGION"}},
+
+    {NL80211_ATTR_DISABLE_HT, {"DISABLE_HT"}},
+    {NL80211_ATTR_HT_CAPABILITY_MASK, {"HT_CAPABILITY_MASK"}},
+
+    {NL80211_ATTR_NOACK_MAP, {"NOACK_MAP"}},
+
+    {NL80211_ATTR_INACTIVITY_TIMEOUT, {"INACTIVITY_TIMEOUT"}},
+
+    {NL80211_ATTR_RX_SIGNAL_DBM, {"RX_SIGNAL_DBM"}},
+
+    {NL80211_ATTR_BG_SCAN_PERIOD, {"BG_SCAN_PERIOD"}},
+
+    {NL80211_ATTR_WDEV, {"WDEV", DataType::Uint}},
+
+    {NL80211_ATTR_USER_REG_HINT_TYPE, {"USER_REG_HINT_TYPE"}},
+
+    {NL80211_ATTR_CONN_FAILED_REASON, {"CONN_FAILED_REASON"}},
+
+    {NL80211_ATTR_AUTH_DATA, {"AUTH_DATA"}},
+
+    {NL80211_ATTR_VHT_CAPABILITY, {"VHT_CAPABILITY"}},
+
+    {NL80211_ATTR_SCAN_FLAGS, {"SCAN_FLAGS", DataType::Uint}},
+
+    {NL80211_ATTR_CHANNEL_WIDTH, {"CHANNEL_WIDTH"}},
+    {NL80211_ATTR_CENTER_FREQ1, {"CENTER_FREQ1"}},
+    {NL80211_ATTR_CENTER_FREQ2, {"CENTER_FREQ2"}},
+
+    {NL80211_ATTR_P2P_CTWINDOW, {"P2P_CTWINDOW"}},
+    {NL80211_ATTR_P2P_OPPPS, {"P2P_OPPPS"}},
+
+    {NL80211_ATTR_LOCAL_MESH_POWER_MODE, {"LOCAL_MESH_POWER_MODE"}},
+
+    {NL80211_ATTR_ACL_POLICY, {"ACL_POLICY"}},
+
+    {NL80211_ATTR_MAC_ADDRS, {"MAC_ADDRS"}},
+
+    {NL80211_ATTR_MAC_ACL_MAX, {"MAC_ACL_MAX", DataType::Uint}},
+
+    {NL80211_ATTR_RADAR_EVENT, {"RADAR_EVENT"}},
+
+    {NL80211_ATTR_EXT_CAPA, {"EXT_CAPA"}},
+    {NL80211_ATTR_EXT_CAPA_MASK, {"EXT_CAPA_MASK"}},
+
+    {NL80211_ATTR_STA_CAPABILITY, {"STA_CAPABILITY"}},
+    {NL80211_ATTR_STA_EXT_CAPABILITY, {"STA_EXT_CAPABILITY"}},
+
+    {NL80211_ATTR_PROTOCOL_FEATURES, {"PROTOCOL_FEATURES", DataType::Uint}},
+    {NL80211_ATTR_SPLIT_WIPHY_DUMP, {"SPLIT_WIPHY_DUMP", DataType::Flag}},
+
+    {NL80211_ATTR_DISABLE_VHT, {"DISABLE_VHT", DataType::Flag}},
+    {NL80211_ATTR_VHT_CAPABILITY_MASK, {"VHT_CAPABILITY_MASK"}},
+
+    {NL80211_ATTR_MDID, {"MDID"}},
+    {NL80211_ATTR_IE_RIC, {"IE_RIC"}},
+
+    {NL80211_ATTR_CRIT_PROT_ID, {"CRIT_PROT_ID"}},
+    {NL80211_ATTR_MAX_CRIT_PROT_DURATION, {"MAX_CRIT_PROT_DURATION"}},
+
+    {NL80211_ATTR_PEER_AID, {"PEER_AID"}},
+
+    {NL80211_ATTR_COALESCE_RULE, {"COALESCE_RULE"}},
+
+    {NL80211_ATTR_CH_SWITCH_COUNT, {"CH_SWITCH_COUNT"}},
+    {NL80211_ATTR_CH_SWITCH_BLOCK_TX, {"CH_SWITCH_BLOCK_TX"}},
+    {NL80211_ATTR_CSA_IES, {"CSA_IES"}},
+    {NL80211_ATTR_CNTDWN_OFFS_BEACON, {"CNTDWN_OFFS_BEACON"}},
+    {NL80211_ATTR_CNTDWN_OFFS_PRESP, {"CNTDWN_OFFS_PRESP"}},
+
+    {NL80211_ATTR_RXMGMT_FLAGS, {"RXMGMT_FLAGS"}},
+
+    {NL80211_ATTR_STA_SUPPORTED_CHANNELS, {"STA_SUPPORTED_CHANNELS"}},
+
+    {NL80211_ATTR_STA_SUPPORTED_OPER_CLASSES, {"STA_SUPPORTED_OPER_CLASSES"}},
+
+    {NL80211_ATTR_HANDLE_DFS, {"HANDLE_DFS"}},
+
+    {NL80211_ATTR_SUPPORT_5_MHZ, {"SUPPORT_5_MHZ"}},
+    {NL80211_ATTR_SUPPORT_10_MHZ, {"SUPPORT_10_MHZ"}},
+
+    {NL80211_ATTR_OPMODE_NOTIF, {"OPMODE_NOTIF"}},
+
+    {NL80211_ATTR_VENDOR_ID, {"VENDOR_ID"}},
+    {NL80211_ATTR_VENDOR_SUBCMD, {"VENDOR_SUBCMD"}},
+    {NL80211_ATTR_VENDOR_DATA, {"VENDOR_DATA", DataType::Raw, AttributeMap{}, Flags::Verbose}},
+    {NL80211_ATTR_VENDOR_EVENTS, {"VENDOR_EVENTS", DataType::Nested, AttributeMap{},
+            Flags::Verbose}},
+
+    {NL80211_ATTR_QOS_MAP, {"QOS_MAP"}},
+
+    {NL80211_ATTR_MAC_HINT, {"MAC_HINT"}},
+    {NL80211_ATTR_WIPHY_FREQ_HINT, {"WIPHY_FREQ_HINT"}},
+
+    {NL80211_ATTR_MAX_AP_ASSOC_STA, {"MAX_AP_ASSOC_STA"}},
+
+    {NL80211_ATTR_TDLS_PEER_CAPABILITY, {"TDLS_PEER_CAPABILITY"}},
+
+    {NL80211_ATTR_SOCKET_OWNER, {"SOCKET_OWNER"}},
+
+    {NL80211_ATTR_CSA_C_OFFSETS_TX, {"CSA_C_OFFSETS_TX"}},
+    {NL80211_ATTR_MAX_CSA_COUNTERS, {"MAX_CSA_COUNTERS"}},
+
+    {NL80211_ATTR_TDLS_INITIATOR, {"TDLS_INITIATOR"}},
+
+    {NL80211_ATTR_USE_RRM, {"USE_RRM"}},
+
+    {NL80211_ATTR_WIPHY_DYN_ACK, {"WIPHY_DYN_ACK"}},
+
+    {NL80211_ATTR_TSID, {"TSID"}},
+    {NL80211_ATTR_USER_PRIO, {"USER_PRIO"}},
+    {NL80211_ATTR_ADMITTED_TIME, {"ADMITTED_TIME"}},
+
+    {NL80211_ATTR_SMPS_MODE, {"SMPS_MODE"}},
+
+    {NL80211_ATTR_OPER_CLASS, {"OPER_CLASS"}},
+
+    {NL80211_ATTR_MAC_MASK, {"MAC_MASK"}},
+
+    {NL80211_ATTR_WIPHY_SELF_MANAGED_REG, {"WIPHY_SELF_MANAGED_REG"}},
+
+    {NL80211_ATTR_EXT_FEATURES, {"EXT_FEATURES"}},
+
+    {NL80211_ATTR_SURVEY_RADIO_STATS, {"SURVEY_RADIO_STATS"}},
+
+    {NL80211_ATTR_NETNS_FD, {"NETNS_FD"}},
+
+    {NL80211_ATTR_SCHED_SCAN_DELAY, {"SCHED_SCAN_DELAY"}},
+
+    {NL80211_ATTR_REG_INDOOR, {"REG_INDOOR"}},
+
+    {NL80211_ATTR_MAX_NUM_SCHED_SCAN_PLANS, {"MAX_NUM_SCHED_SCAN_PLANS", DataType::Uint}},
+    {NL80211_ATTR_MAX_SCAN_PLAN_INTERVAL, {"MAX_SCAN_PLAN_INTERVAL", DataType::Uint}},
+    {NL80211_ATTR_MAX_SCAN_PLAN_ITERATIONS, {"MAX_SCAN_PLAN_ITERATIONS", DataType::Uint}},
+    {NL80211_ATTR_SCHED_SCAN_PLANS, {"SCHED_SCAN_PLANS"}},
+
+    {NL80211_ATTR_PBSS, {"PBSS"}},
+
+    {NL80211_ATTR_BSS_SELECT, {"BSS_SELECT"}},
+
+    {NL80211_ATTR_STA_SUPPORT_P2P_PS, {"STA_SUPPORT_P2P_PS"}},
+
+    {NL80211_ATTR_PAD, {"PAD"}},
+
+    {NL80211_ATTR_IFTYPE_EXT_CAPA, {"IFTYPE_EXT_CAPA"}},
+
+    {NL80211_ATTR_MU_MIMO_GROUP_DATA, {"MU_MIMO_GROUP_DATA"}},
+    {NL80211_ATTR_MU_MIMO_FOLLOW_MAC_ADDR, {"MU_MIMO_FOLLOW_MAC_ADDR"}},
+
+    {NL80211_ATTR_SCAN_START_TIME_TSF, {"SCAN_START_TIME_TSF"}},
+    {NL80211_ATTR_SCAN_START_TIME_TSF_BSSID, {"SCAN_START_TIME_TSF_BSSID"}},
+    {NL80211_ATTR_MEASUREMENT_DURATION, {"MEASUREMENT_DURATION"}},
+    {NL80211_ATTR_MEASUREMENT_DURATION_MANDATORY, {"MEASUREMENT_DURATION_MANDATORY"}},
+
+    {NL80211_ATTR_MESH_PEER_AID, {"MESH_PEER_AID"}},
+
+    {NL80211_ATTR_NAN_MASTER_PREF, {"NAN_MASTER_PREF"}},
+    {NL80211_ATTR_BANDS, {"BANDS"}},
+    {NL80211_ATTR_NAN_FUNC, {"NAN_FUNC"}},
+    {NL80211_ATTR_NAN_MATCH, {"NAN_MATCH"}},
+
+    {NL80211_ATTR_FILS_KEK, {"FILS_KEK"}},
+    {NL80211_ATTR_FILS_NONCES, {"FILS_NONCES"}},
+
+    {NL80211_ATTR_MULTICAST_TO_UNICAST_ENABLED, {"MULTICAST_TO_UNICAST_ENABLED"}},
+
+    {NL80211_ATTR_BSSID, {"BSSID"}},
+
+    {NL80211_ATTR_SCHED_SCAN_RELATIVE_RSSI, {"SCHED_SCAN_RELATIVE_RSSI"}},
+    {NL80211_ATTR_SCHED_SCAN_RSSI_ADJUST, {"SCHED_SCAN_RSSI_ADJUST"}},
+
+    {NL80211_ATTR_TIMEOUT_REASON, {"TIMEOUT_REASON"}},
+
+    {NL80211_ATTR_FILS_ERP_USERNAME, {"FILS_ERP_USERNAME"}},
+    {NL80211_ATTR_FILS_ERP_REALM, {"FILS_ERP_REALM"}},
+    {NL80211_ATTR_FILS_ERP_NEXT_SEQ_NUM, {"FILS_ERP_NEXT_SEQ_NUM"}},
+    {NL80211_ATTR_FILS_ERP_RRK, {"FILS_ERP_RRK"}},
+    {NL80211_ATTR_FILS_CACHE_ID, {"FILS_CACHE_ID"}},
+
+    {NL80211_ATTR_PMK, {"PMK"}},
+
+    {NL80211_ATTR_SCHED_SCAN_MULTI, {"SCHED_SCAN_MULTI"}},
+    {NL80211_ATTR_SCHED_SCAN_MAX_REQS, {"SCHED_SCAN_MAX_REQS"}},
+
+    {NL80211_ATTR_WANT_1X_4WAY_HS, {"WANT_1X_4WAY_HS"}},
+    {NL80211_ATTR_PMKR0_NAME, {"PMKR0_NAME"}},
+    {NL80211_ATTR_PORT_AUTHORIZED, {"PORT_AUTHORIZED"}},
+
+    {NL80211_ATTR_EXTERNAL_AUTH_ACTION, {"EXTERNAL_AUTH_ACTION"}},
+    {NL80211_ATTR_EXTERNAL_AUTH_SUPPORT, {"EXTERNAL_AUTH_SUPPORT"}},
+
+    {NL80211_ATTR_NSS, {"NSS"}},
+    {NL80211_ATTR_ACK_SIGNAL, {"ACK_SIGNAL"}},
+
+    {NL80211_ATTR_CONTROL_PORT_OVER_NL80211, {"CONTROL_PORT_OVER_NL80211"}},
+
+    {NL80211_ATTR_TXQ_STATS, {"TXQ_STATS"}},
+    {NL80211_ATTR_TXQ_LIMIT, {"TXQ_LIMIT"}},
+    {NL80211_ATTR_TXQ_MEMORY_LIMIT, {"TXQ_MEMORY_LIMIT"}},
+    {NL80211_ATTR_TXQ_QUANTUM, {"TXQ_QUANTUM"}},
+
+    {NL80211_ATTR_HE_CAPABILITY, {"HE_CAPABILITY"}},
+
+    {NL80211_ATTR_FTM_RESPONDER, {"FTM_RESPONDER"}},
+
+    {NL80211_ATTR_FTM_RESPONDER_STATS, {"FTM_RESPONDER_STATS"}},
+
+    {NL80211_ATTR_TIMEOUT, {"TIMEOUT"}},
+
+    {NL80211_ATTR_PEER_MEASUREMENTS, {"PEER_MEASUREMENTS"}},
+
+    {NL80211_ATTR_AIRTIME_WEIGHT, {"AIRTIME_WEIGHT"}},
+    {NL80211_ATTR_STA_TX_POWER_SETTING, {"STA_TX_POWER_SETTING"}},
+    {NL80211_ATTR_STA_TX_POWER, {"STA_TX_POWER"}},
+
+    {NL80211_ATTR_SAE_PASSWORD, {"SAE_PASSWORD"}},
+
+    {NL80211_ATTR_TWT_RESPONDER, {"TWT_RESPONDER"}},
+
+    {NL80211_ATTR_HE_OBSS_PD, {"HE_OBSS_PD"}},
+
+    {NL80211_ATTR_WIPHY_EDMG_CHANNELS, {"WIPHY_EDMG_CHANNELS"}},
+    {NL80211_ATTR_WIPHY_EDMG_BW_CONFIG, {"WIPHY_EDMG_BW_CONFIG"}},
+
+    {NL80211_ATTR_VLAN_ID, {"VLAN_ID"}},
+
+    {NL80211_ATTR_HE_BSS_COLOR, {"HE_BSS_COLOR"}},
+
+    {NL80211_ATTR_IFTYPE_AKM_SUITES, {"IFTYPE_AKM_SUITES"}},
+
+    {NL80211_ATTR_TID_CONFIG, {"TID_CONFIG"}},
+
+    {NL80211_ATTR_CONTROL_PORT_NO_PREAUTH, {"CONTROL_PORT_NO_PREAUTH"}},
+
+    {NL80211_ATTR_PMK_LIFETIME, {"PMK_LIFETIME"}},
+    {NL80211_ATTR_PMK_REAUTH_THRESHOLD, {"PMK_REAUTH_THRESHOLD"}},
+
+    {NL80211_ATTR_RECEIVE_MULTICAST, {"RECEIVE_MULTICAST"}},
+    {NL80211_ATTR_WIPHY_FREQ_OFFSET, {"WIPHY_FREQ_OFFSET"}},
+    {NL80211_ATTR_CENTER_FREQ1_OFFSET, {"CENTER_FREQ1_OFFSET"}},
+    {NL80211_ATTR_SCAN_FREQ_KHZ, {"SCAN_FREQ_KHZ"}},
+
+    {NL80211_ATTR_HE_6GHZ_CAPABILITY, {"HE_6GHZ_CAPABILITY"}},
+
+    {NL80211_ATTR_FILS_DISCOVERY, {"FILS_DISCOVERY"}},
+
+    {NL80211_ATTR_UNSOL_BCAST_PROBE_RESP, {"UNSOL_BCAST_PROBE_RESP"}},
+
+    {NL80211_ATTR_S1G_CAPABILITY, {"S1G_CAPABILITY"}},
+    {NL80211_ATTR_S1G_CAPABILITY_MASK, {"S1G_CAPABILITY_MASK"}},
+}) {}
+// clang-format on
+
+static void informationElementsToStream(std::stringstream& ss, const Buffer<nlattr> attr) {
+    struct IEHeader {
+        uint8_t elementId;
+        uint8_t length;
+    } __attribute__((packed));
+    static_assert(sizeof(IEHeader) == 2);
+
+    const auto alldata = attr.data<uint8_t>();
+    const auto bytes = alldata.getRaw();
+
+    ss << '{';
+
+    if constexpr (kCompactIE) {
+        ss << "len=" << bytes.len() << ", ";
+        ss << "crc=" << std::hex << std::setw(4) << crc16(alldata) << std::dec << ", ";
+    }
+
+    bool first = true;
+    auto printComma = [&first, &ss]() {
+        // put separator at every but first entry
+        if (!first) ss << ", ";
+        first = false;
+    };
+
+    for (size_t offset = 0; offset < bytes.len();) {
+        const auto ptr = bytes.ptr() + offset;
+        const auto remainingLen = bytes.len() - offset;
+
+        // can we fit one more header?
+        if (sizeof(IEHeader) > remainingLen) break;
+        IEHeader ieHeader;
+        memcpy(&ieHeader, ptr, sizeof(IEHeader));
+        if (sizeof(IEHeader) + ieHeader.length > remainingLen) {
+            printComma();
+            ss << "ERR";
+            break;
+        }
+        offset += sizeof(IEHeader) + ieHeader.length;
+
+        const Buffer<uint8_t> data(ptr + sizeof(IEHeader), ieHeader.length);
+
+        if (ieHeader.elementId == WLAN_EID_SSID) {
+            printComma();
+
+            const auto str = data.getRaw();
+            const std::string ssid(reinterpret_cast<const char*>(str.ptr()), str.len());
+            ss << "SSID=\"" << printableOnly(ssid) << '"';
+
+            continue;
+        }
+
+        if constexpr (kCompactIE) continue;
+
+        // print entry ID:LENGTH/CRC16
+        printComma();
+        ss << (int)ieHeader.elementId << ':' << (int)ieHeader.length << '/';
+        ss << std::hex << std::setw(4) << crc16(data) << std::dec;
+    }
+    ss << '}';
+}
+
+static void nl80211_pattern_supportToStream(std::stringstream& ss, const Buffer<nlattr> attr) {
+    const auto& [ok, data] = attr.data<nl80211_pattern_support>().getFirst();
+    if (!ok) {
+        ss << "invalid structure";
+        return;
+    }
+    ss << '{'                          //
+       << data.max_patterns << ','     //
+       << data.min_pattern_len << ','  //
+       << data.max_pattern_len << ','  //
+       << data.max_pkt_offset << '}';
+}
+
+}  // namespace android::nl::protocols::generic::families
diff --git a/keymint/aidl/android/hardware/keymint/EcCurve.aidl b/automotive/can/1.0/default/libnl++/protocols/generic/families/Nl80211.h
similarity index 70%
copy from keymint/aidl/android/hardware/keymint/EcCurve.aidl
copy to automotive/can/1.0/default/libnl++/protocols/generic/families/Nl80211.h
index abd44b4..8a9608c 100644
--- a/keymint/aidl/android/hardware/keymint/EcCurve.aidl
+++ b/automotive/can/1.0/default/libnl++/protocols/generic/families/Nl80211.h
@@ -14,17 +14,15 @@
  * limitations under the License.
  */
 
-package android.hardware.keymint;
+#pragma once
 
+#include "../GenericMessageBase.h"
 
-/**
- * Supported EC curves, used in ECDSA
- */
-@VintfStability
-@Backing(type="int")
-enum EcCurve {
-    P_224 = 0,
-    P_256 = 1,
-    P_384 = 2,
-    P_521 = 3,
-}
+namespace android::nl::protocols::generic::families {
+
+class Nl80211 : public GenericMessageBase {
+  public:
+    Nl80211(nlmsgtype_t familyId);
+};
+
+}  // namespace android::nl::protocols::generic::families
diff --git a/automotive/can/1.0/default/libnl++/protocols/route/Link.cpp b/automotive/can/1.0/default/libnl++/protocols/route/Link.cpp
index 7db487a..9cc05da 100644
--- a/automotive/can/1.0/default/libnl++/protocols/route/Link.cpp
+++ b/automotive/can/1.0/default/libnl++/protocols/route/Link.cpp
@@ -16,6 +16,7 @@
 
 #include "Link.h"
 
+#include "../structs.h"
 #include "structs.h"
 
 #include <net/if.h>
@@ -26,9 +27,9 @@
 
 // clang-format off
 Link::Link() : MessageDefinition<ifinfomsg>("link", {
-    {RTM_NEWLINK, {"NEWLINK", MessageGenre::NEW}},
-    {RTM_DELLINK, {"DELLINK", MessageGenre::DELETE}},
-    {RTM_GETLINK, {"GETLINK", MessageGenre::GET}},
+    {RTM_NEWLINK, {"NEWLINK", MessageGenre::New}},
+    {RTM_DELLINK, {"DELLINK", MessageGenre::Delete}},
+    {RTM_GETLINK, {"GETLINK", MessageGenre::Get}},
 }, {
     {IFLA_ADDRESS, {"ADDRESS"}},
     {IFLA_BROADCAST, {"BROADCAST"}},
diff --git a/automotive/can/1.0/default/libnl++/protocols/route/structs.h b/automotive/can/1.0/default/libnl++/protocols/route/structs.h
index b9d622a..fea2ce1 100644
--- a/automotive/can/1.0/default/libnl++/protocols/route/structs.h
+++ b/automotive/can/1.0/default/libnl++/protocols/route/structs.h
@@ -30,16 +30,6 @@
 // ifla_cacheinfo
 void ifla_cacheinfoToStream(std::stringstream& ss, const Buffer<nlattr> attr);
 
-template <typename T>
-void arrayToStream(std::stringstream& ss, const Buffer<nlattr> attr) {
-    ss << '{';
-    for (const auto it : attr.data<T>().getRaw()) {
-        ss << it << ',';
-    }
-    ss.seekp(-1, std::ios_base::cur);
-    ss << '}';
-}
-
 // rtnl_link_stats or rtnl_link_stats64
 template <typename T>
 void statsToStream(std::stringstream& ss, const Buffer<nlattr> attr) {
diff --git a/keymint/aidl/android/hardware/keymint/EcCurve.aidl b/automotive/can/1.0/default/libnl++/protocols/structs.h
similarity index 63%
copy from keymint/aidl/android/hardware/keymint/EcCurve.aidl
copy to automotive/can/1.0/default/libnl++/protocols/structs.h
index abd44b4..44c17b8 100644
--- a/keymint/aidl/android/hardware/keymint/EcCurve.aidl
+++ b/automotive/can/1.0/default/libnl++/protocols/structs.h
@@ -14,17 +14,20 @@
  * limitations under the License.
  */
 
-package android.hardware.keymint;
+#pragma once
 
+#include <sstream>
 
-/**
- * Supported EC curves, used in ECDSA
- */
-@VintfStability
-@Backing(type="int")
-enum EcCurve {
-    P_224 = 0,
-    P_256 = 1,
-    P_384 = 2,
-    P_521 = 3,
+namespace android::nl::protocols {
+
+template <typename T>
+void arrayToStream(std::stringstream& ss, const Buffer<nlattr> attr) {
+    ss << '{';
+    for (const auto it : attr.data<T>().getRaw()) {
+        ss << it << ',';
+    }
+    ss.seekp(-1, std::ios_base::cur);
+    ss << '}';
 }
+
+}  // namespace android::nl::protocols
diff --git a/automotive/evs/1.1/vts/functional/VtsHalEvsV1_1TargetTest.cpp b/automotive/evs/1.1/vts/functional/VtsHalEvsV1_1TargetTest.cpp
index 8de9304..e56c2d1 100644
--- a/automotive/evs/1.1/vts/functional/VtsHalEvsV1_1TargetTest.cpp
+++ b/automotive/evs/1.1/vts/functional/VtsHalEvsV1_1TargetTest.cpp
@@ -305,11 +305,22 @@
             const auto id = 0xFFFFFFFF; // meaningless id
             hidl_vec<uint8_t> values;
             auto err = pCam->setExtendedInfo_1_1(id, values);
-            ASSERT_NE(EvsResult::INVALID_ARG, err);
+            if (isLogicalCam) {
+                // Logical camera device does not support setExtendedInfo
+                // method.
+                ASSERT_EQ(EvsResult::INVALID_ARG, err);
+            } else {
+                ASSERT_NE(EvsResult::INVALID_ARG, err);
+            }
 
-            pCam->getExtendedInfo_1_1(id, [](const auto& result, const auto& data) {
-                ASSERT_NE(EvsResult::INVALID_ARG, result);
-                ASSERT_EQ(0, data.size());
+
+            pCam->getExtendedInfo_1_1(id, [&isLogicalCam](const auto& result, const auto& data) {
+                if (isLogicalCam) {
+                    ASSERT_EQ(EvsResult::INVALID_ARG, result);
+                } else {
+                    ASSERT_NE(EvsResult::INVALID_ARG, result);
+                    ASSERT_EQ(0, data.size());
+                }
             });
 
             // Explicitly close the camera so resources are released right away
diff --git a/automotive/vehicle/2.0/default/Android.bp b/automotive/vehicle/2.0/default/Android.bp
index 8d1693a..bbb48e1 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",
     ],
 }
@@ -210,6 +210,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/impl/vhal_v2_0/DefaultConfig.h b/automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultConfig.h
index 5ecce46..8ef2b60 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
@@ -308,6 +308,19 @@
 
         {.config =
                  {
+                         .prop = toInt(VehicleProperty::SEAT_OCCUPANCY),
+                         .access = VehiclePropertyAccess::READ,
+                         .changeMode = VehiclePropertyChangeMode::ON_CHANGE,
+                         .areaConfigs = {VehicleAreaConfig{.areaId = (SEAT_1_LEFT)},
+                                         VehicleAreaConfig{.areaId = (SEAT_1_RIGHT)}},
+                 },
+         .initialAreaValues = {{SEAT_1_LEFT,
+                                {.int32Values = {(int)VehicleSeatOccupancyState::VACANT}}},
+                               {SEAT_1_RIGHT,
+                                {.int32Values = {(int)VehicleSeatOccupancyState::VACANT}}}}},
+
+        {.config =
+                 {
                          .prop = toInt(VehicleProperty::INFO_DRIVER_SEAT),
                          .access = VehiclePropertyAccess::READ,
                          .changeMode = VehiclePropertyChangeMode::STATIC,
diff --git a/biometrics/face/aidl/default/Face.cpp b/biometrics/face/aidl/default/Face.cpp
index d3883d6..773359e 100644
--- a/biometrics/face/aidl/default/Face.cpp
+++ b/biometrics/face/aidl/default/Face.cpp
@@ -19,7 +19,7 @@
 
 namespace aidl::android::hardware::biometrics::face {
 
-const int kSensorId = 0;
+const int kSensorId = 4;
 const common::SensorStrength kSensorStrength = common::SensorStrength::STRONG;
 const int kMaxEnrollmentsPerUser = 5;
 const FaceSensorType kSensorType = FaceSensorType::RGB;
diff --git a/bluetooth/audio/2.1/default/BluetoothAudioProvider.cpp b/bluetooth/audio/2.1/default/BluetoothAudioProvider.cpp
index 092038b..73fe06c 100644
--- a/bluetooth/audio/2.1/default/BluetoothAudioProvider.cpp
+++ b/bluetooth/audio/2.1/default/BluetoothAudioProvider.cpp
@@ -57,14 +57,14 @@
 
   if (audioConfig.getDiscriminator() ==
       V2_0::AudioConfiguration::hidl_discriminator::pcmConfig) {
-    audioConfig_2_1.pcmConfig() = {
+    audioConfig_2_1.pcmConfig({
         .sampleRate =
             static_cast<SampleRate>(audioConfig.pcmConfig().sampleRate),
         .channelMode = audioConfig.pcmConfig().channelMode,
         .bitsPerSample = audioConfig.pcmConfig().bitsPerSample,
-        .dataIntervalUs = 0};
+        .dataIntervalUs = 0});
   } else {
-    audioConfig_2_1.codecConfig() = audioConfig.codecConfig();
+    audioConfig_2_1.codecConfig(audioConfig.codecConfig());
   }
 
   return startSession_2_1(hostIf, audioConfig_2_1, _hidl_cb);
diff --git a/common/TEST_MAPPING b/common/TEST_MAPPING
new file mode 100644
index 0000000..7dd29e5
--- /dev/null
+++ b/common/TEST_MAPPING
@@ -0,0 +1,7 @@
+{
+  "presubmit": [
+    {
+      "name": "libaidlcommonsupport_test"
+    }
+  ]
+}
diff --git a/common/support/Android.bp b/common/support/Android.bp
new file mode 100644
index 0000000..3bb4804
--- /dev/null
+++ b/common/support/Android.bp
@@ -0,0 +1,27 @@
+cc_library_static {
+    name: "libaidlcommonsupport",
+    vendor_available: true,
+    host_supported: true,
+    defaults: ["libbinder_ndk_host_user"],
+    srcs: ["NativeHandle.cpp"],
+    export_include_dirs: ["include"],
+    shared_libs: [
+        "android.hardware.common-unstable-ndk_platform",
+        "libcutils",
+    ],
+}
+
+cc_test {
+    name: "libaidlcommonsupport_test",
+    host_supported: true,
+    defaults: ["libbinder_ndk_host_user"],
+    srcs: ["test.cpp"],
+    static_libs: [
+        "libaidlcommonsupport",
+    ],
+    shared_libs: [
+        "android.hardware.common-unstable-ndk_platform",
+        "libcutils",
+    ],
+    test_suites: ["general-tests"],
+}
diff --git a/common/support/NativeHandle.cpp b/common/support/NativeHandle.cpp
new file mode 100644
index 0000000..321d7a8
--- /dev/null
+++ b/common/support/NativeHandle.cpp
@@ -0,0 +1,66 @@
+/*
+ * 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 <aidlcommonsupport/NativeHandle.h>
+
+#include <fcntl.h>
+
+namespace android {
+
+using aidl::android::hardware::common::NativeHandle;
+
+static native_handle_t* fromAidl(const NativeHandle& handle, bool doDup) {
+    native_handle_t* to = native_handle_create(handle.fds.size(), handle.ints.size());
+    if (!to) return nullptr;
+
+    for (size_t i = 0; i < handle.fds.size(); i++) {
+        int fd = handle.fds[i].get();
+        to->data[i] = doDup ? fcntl(fd, F_DUPFD_CLOEXEC, 0) : fd;
+    }
+    memcpy(to->data + handle.fds.size(), handle.ints.data(), handle.ints.size() * sizeof(int));
+    return to;
+}
+
+native_handle_t* makeFromAidl(const NativeHandle& handle) {
+    return fromAidl(handle, false /* doDup */);
+}
+native_handle_t* dupFromAidl(const NativeHandle& handle) {
+    return fromAidl(handle, true /* doDup */);
+}
+
+static NativeHandle toAidl(const native_handle_t* handle, bool doDup) {
+    NativeHandle to;
+
+    to.fds = std::vector<ndk::ScopedFileDescriptor>(handle->numFds);
+    for (size_t i = 0; i < handle->numFds; i++) {
+        int fd = handle->data[i];
+        to.fds.at(i).set(doDup ? fcntl(fd, F_DUPFD_CLOEXEC, 0) : fd);
+    }
+
+    to.ints = std::vector<int32_t>(handle->data + handle->numFds,
+                                   handle->data + handle->numFds + handle->numInts);
+    return to;
+}
+
+NativeHandle makeToAidl(const native_handle_t* handle) {
+    return toAidl(handle, false /* doDup */);
+}
+
+NativeHandle dupToAidl(const native_handle_t* handle) {
+    return toAidl(handle, true /* doDup */);
+}
+
+}  // namespace android
diff --git a/common/support/include/aidlcommonsupport/NativeHandle.h b/common/support/include/aidlcommonsupport/NativeHandle.h
new file mode 100644
index 0000000..10eecba
--- /dev/null
+++ b/common/support/include/aidlcommonsupport/NativeHandle.h
@@ -0,0 +1,53 @@
+/*
+ * 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.
+ */
+
+#pragma once
+
+#include <aidl/android/hardware/common/NativeHandle.h>
+#include <cutils/native_handle.h>
+
+namespace android {
+
+/**
+ * Creates a libcutils native handle from an AIDL native handle, but it does not
+ * dup internally, so it will contain the same FDs as the handle itself. The
+ * result should be deleted with native_handle_delete.
+ */
+native_handle_t* makeFromAidl(const aidl::android::hardware::common::NativeHandle& handle);
+
+/**
+ * Creates a libcutils native handle from an AIDL native handle with a dup
+ * internally. It's expected the handle is cleaned up with native_handle_close
+ * and native_handle_delete.
+ */
+native_handle_t* dupFromAidl(const aidl::android::hardware::common::NativeHandle& handle);
+
+/**
+ * Creates an AIDL native handle from a libcutils native handle, but does not
+ * dup internally, so the result will contain the same FDs as the handle itself.
+ *
+ * Warning: this passes ownership of the FDs to the ScopedFileDescriptor
+ * objects.
+ */
+aidl::android::hardware::common::NativeHandle makeToAidl(const native_handle_t* handle);
+
+/**
+ * Creates an AIDL native handle from a libcutils native handle with a dup
+ * internally.
+ */
+aidl::android::hardware::common::NativeHandle dupToAidl(const native_handle_t* handle);
+
+}  // namespace android
diff --git a/common/support/test.cpp b/common/support/test.cpp
new file mode 100644
index 0000000..2359277
--- /dev/null
+++ b/common/support/test.cpp
@@ -0,0 +1,138 @@
+/*
+ * 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 <aidlcommonsupport/NativeHandle.h>
+#include <gtest/gtest.h>
+
+namespace android {
+
+using aidl::android::hardware::common::NativeHandle;
+using ndk::ScopedFileDescriptor;
+
+static void checkEq(const NativeHandle& aidl, native_handle_t* libcutils, bool exceptFds) {
+    ASSERT_NE(libcutils, nullptr);
+    ASSERT_EQ(libcutils->numFds, aidl.fds.size());
+
+    for (size_t i = 0; i < libcutils->numFds; i++) {
+        int afd = aidl.fds.at(i).get();
+        int lfd = libcutils->data[i];
+
+        EXPECT_GE(afd, 0) << "Invalid fd at index " << i;
+        EXPECT_GE(lfd, 0) << "Invalid fd at index " << i;
+
+        if (exceptFds) {
+            EXPECT_NE(afd, lfd) << "Index matched at " << i << " but should be dup'd fd";
+        } else {
+            EXPECT_EQ(afd, lfd) << "Index mismatched at " << i << " but should be same fd";
+        }
+    }
+
+    ASSERT_EQ(libcutils->numInts, aidl.ints.size());
+
+    for (size_t i = 0; i < libcutils->numInts; i++) {
+        int afd = aidl.ints.at(i);
+        int lfd = libcutils->data[libcutils->numFds + i];
+
+        EXPECT_EQ(afd, lfd) << "Index mismatch at " << i;
+    }
+}
+
+static NativeHandle makeTestAidlHandle() {
+    NativeHandle handle = {
+            .fds = std::vector<ScopedFileDescriptor>(2),
+            .ints = {1, 2, 3, 4},
+    };
+    handle.fds[0].set(dup(0));
+    handle.fds[1].set(dup(0));
+    return handle;
+}
+
+TEST(ConvertNativeHandle, MakeFromAidlEmpty) {
+    NativeHandle handle;
+    native_handle_t* to = makeFromAidl(handle);
+    checkEq(handle, to, false /*exceptFds*/);
+    // no native_handle_close b/c fds are owned by NativeHandle
+    EXPECT_EQ(0, native_handle_delete(to));
+}
+
+TEST(ConvertNativeHandle, MakeFromAidl) {
+    NativeHandle handle = makeTestAidlHandle();
+    native_handle_t* to = makeFromAidl(handle);
+    checkEq(handle, to, false /*exceptFds*/);
+    // no native_handle_close b/c fds are owned by NativeHandle
+    EXPECT_EQ(0, native_handle_delete(to));
+}
+
+TEST(ConvertNativeHandle, DupFromAidlEmpty) {
+    NativeHandle handle;
+    native_handle_t* to = dupFromAidl(handle);
+    checkEq(handle, to, true /*exceptFds*/);
+    EXPECT_EQ(0, native_handle_close(to));
+    EXPECT_EQ(0, native_handle_delete(to));
+}
+
+TEST(ConvertNativeHandle, DupFromAidl) {
+    NativeHandle handle = makeTestAidlHandle();
+    native_handle_t* to = dupFromAidl(handle);
+    checkEq(handle, to, true /*exceptFds*/);
+    EXPECT_EQ(0, native_handle_close(to));
+    EXPECT_EQ(0, native_handle_delete(to));
+}
+
+static native_handle_t* makeTestLibcutilsHandle() {
+    native_handle_t* handle = native_handle_create(2, 4);
+    handle->data[0] = dup(0);
+    handle->data[1] = dup(0);
+    handle->data[2] = 1;
+    handle->data[3] = 2;
+    handle->data[4] = 3;
+    handle->data[5] = 4;
+    return handle;
+}
+
+TEST(ConvertNativeHandle, MakeToAidlEmpty) {
+    native_handle_t* handle = native_handle_create(0, 0);
+    NativeHandle to = makeToAidl(handle);
+    checkEq(to, handle, false /*exceptFds*/);
+    // no native_handle_close b/c fds are owned by NativeHandle now
+    EXPECT_EQ(0, native_handle_delete(handle));
+}
+
+TEST(ConvertNativeHandle, MakeToAidl) {
+    native_handle_t* handle = makeTestLibcutilsHandle();
+    NativeHandle to = makeToAidl(handle);
+    checkEq(to, handle, false /*exceptFds*/);
+    // no native_handle_close b/c fds are owned by NativeHandle now
+    EXPECT_EQ(0, native_handle_delete(handle));
+}
+
+TEST(ConvertNativeHandle, DupToAidlEmpty) {
+    native_handle_t* handle = native_handle_create(0, 0);
+    NativeHandle to = dupToAidl(handle);
+    checkEq(to, handle, true /*exceptFds*/);
+    EXPECT_EQ(0, native_handle_close(handle));
+    EXPECT_EQ(0, native_handle_delete(handle));
+}
+
+TEST(ConvertNativeHandle, DupToAidl) {
+    native_handle_t* handle = makeTestLibcutilsHandle();
+    NativeHandle to = dupToAidl(handle);
+    checkEq(to, handle, true /*exceptFds*/);
+    EXPECT_EQ(0, native_handle_close(handle));
+    EXPECT_EQ(0, native_handle_delete(handle));
+}
+
+}  // namespace android
diff --git a/compatibility_matrices/compatibility_matrix.current.xml b/compatibility_matrices/compatibility_matrix.current.xml
index 72321e2..b16ae40 100644
--- a/compatibility_matrices/compatibility_matrix.current.xml
+++ b/compatibility_matrices/compatibility_matrix.current.xml
@@ -319,7 +319,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/current.txt b/current.txt
index 7aa9593..8623fc0 100644
--- a/current.txt
+++ b/current.txt
@@ -772,12 +772,15 @@
 2c331a9605f3a08d9c1e0a36169ca57758bc43c11a78ef3f3730509885e52c15 android.hardware.graphics.composer@2.4::IComposerClient
 3da3ce039247872d95c6bd48621dbfdfa1c2d2a91a90f257862f87ee2bc46300 android.hardware.health@2.1::types
 9679f27a42f75781c8993ef163ed92808a1928de186639834841d0b8e326e63d android.hardware.gatekeeper@1.0::IGatekeeper
+9c4eb603d7b9ad675a14edb6180681c5a78da5c6bdc7755853912c974a21f7e5 android.hardware.gnss@1.0::IAGnssCallback
 40456eb90ea88b62d18ad3fbf1da8917981cd55ac04ce69c8e058d49ff5beff4 android.hardware.keymaster@3.0::IKeymasterDevice
 6017b4f2481feb0fffceae81c62bc372c898998b2d8fe69fbd39859d3a315e5e android.hardware.keymaster@4.0::IKeymasterDevice
 dabe23dde7c9e3ad65c61def7392f186d7efe7f4216f9b6f9cf0863745b1a9f4 android.hardware.keymaster@4.1::IKeymasterDevice
 cd84ab19c590e0e73dd2307b591a3093ee18147ef95e6d5418644463a6620076 android.hardware.neuralnetworks@1.2::IDevice
 9625e85f56515ad2cf87b6a1847906db669f746ea4ab02cd3d4ca25abc9b0109 android.hardware.neuralnetworks@1.2::types
 9e758e208d14f7256e0885d6d8ad0b61121b21d8c313864f981727ae55bffd16 android.hardware.neuralnetworks@1.3::types
+e8c86c69c438da8d1549856c1bb3e2d1b8da52722f8235ff49a30f2cce91742c android.hardware.soundtrigger@2.1::ISoundTriggerHwCallback
+b9fbb6e2e061ed0960939d48b785e9700210add1f13ed32ecd688d0f1ca20ef7 android.hardware.renderscript@1.0::types
 0f53d70e1eadf8d987766db4bf6ae2048004682168f4cab118da576787def3fa android.hardware.radio@1.0::types
 38d65fb20c60a5b823298560fc0825457ecdc49603a4b4e94bf81511790737da android.hardware.radio@1.4::types
 954c334efd80e8869b66d1ce5fe2755712d96ba4b3c38d415739c330af5fb4cb android.hardware.radio@1.5::types
diff --git a/gnss/1.0/IAGnssCallback.hal b/gnss/1.0/IAGnssCallback.hal
index 81f1689..11a6a5d 100644
--- a/gnss/1.0/IAGnssCallback.hal
+++ b/gnss/1.0/IAGnssCallback.hal
@@ -42,7 +42,6 @@
     /**
      * Represents the status of AGNSS augmented to support IPv4.
      */
-    @export(name="", value_prefix="GPS_")
     struct AGnssStatusIpV4 {
         AGnssType type;
         AGnssStatusValue status;
diff --git a/gnss/1.1/default/Android.bp b/gnss/1.1/default/Android.bp
index 9c498d5..ef43a34 100644
--- a/gnss/1.1/default/Android.bp
+++ b/gnss/1.1/default/Android.bp
@@ -18,6 +18,7 @@
         "android.hardware.gnss@2.0",
         "android.hardware.gnss@1.1",
         "android.hardware.gnss@1.0",
+        "android.hardware.gnss-ndk_platform",
     ],
     static_libs: [
         "android.hardware.gnss@common-default-lib",
diff --git a/gnss/2.0/default/Android.bp b/gnss/2.0/default/Android.bp
index 37de55d..7da462f 100644
--- a/gnss/2.0/default/Android.bp
+++ b/gnss/2.0/default/Android.bp
@@ -29,7 +29,7 @@
         "GnssMeasurement.cpp",
         "GnssMeasurementCorrections.cpp",
         "GnssVisibilityControl.cpp",
-        "service.cpp"
+        "service.cpp",
     ],
     shared_libs: [
         "libhidlbase",
@@ -39,8 +39,9 @@
         "android.hardware.gnss.visibility_control@1.0",
         "android.hardware.gnss@2.1",
         "android.hardware.gnss@2.0",
-        "android.hardware.gnss@1.0",
         "android.hardware.gnss@1.1",
+        "android.hardware.gnss@1.0",
+        "android.hardware.gnss-ndk_platform",
     ],
     static_libs: [
         "android.hardware.gnss@common-default-lib",
diff --git a/gnss/2.1/default/Android.bp b/gnss/2.1/default/Android.bp
index 7739f90..63e5013 100644
--- a/gnss/2.1/default/Android.bp
+++ b/gnss/2.1/default/Android.bp
@@ -34,6 +34,7 @@
         "android.hardware.gnss@1.0",
         "android.hardware.gnss@1.1",
         "android.hardware.gnss@2.0",
+        "android.hardware.gnss-ndk_platform",
     ],
     static_libs: [
         "android.hardware.gnss@common-default-lib",
diff --git a/gnss/2.1/vts/functional/gnss_hal_test.h b/gnss/2.1/vts/functional/gnss_hal_test.h
index 7950670..2bcecf4 100644
--- a/gnss/2.1/vts/functional/gnss_hal_test.h
+++ b/gnss/2.1/vts/functional/gnss_hal_test.h
@@ -19,10 +19,9 @@
 #include <android/hardware/gnss/2.1/IGnss.h>
 #include "v2_1/gnss_hal_test_template.h"
 
-using android::hardware::gnss::V2_1::IGnss;
-
 // The main test class for GNSS HAL.
-class GnssHalTest : public GnssHalTestTemplate<IGnss> {
+class GnssHalTest : public android::hardware::gnss::common::GnssHalTestTemplate<
+                            android::hardware::gnss::V2_1::IGnss> {
   public:
     /**
      * IsGnssHalVersion_2_1:
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 7afd49c..deb80e8 100644
--- a/gnss/2.1/vts/functional/gnss_hal_test_cases.cpp
+++ b/gnss/2.1/vts/functional/gnss_hal_test_cases.cpp
@@ -27,6 +27,9 @@
 
 using android::hardware::gnss::common::Utils;
 
+using android::hardware::gnss::V2_1::IGnssAntennaInfo;
+using android::hardware::gnss::V2_1::IGnssAntennaInfoCallback;
+
 using IGnssMeasurement_2_1 = android::hardware::gnss::V2_1::IGnssMeasurement;
 using IGnssMeasurement_2_0 = android::hardware::gnss::V2_0::IGnssMeasurement;
 using IGnssMeasurement_1_1 = android::hardware::gnss::V1_1::IGnssMeasurement;
diff --git a/gnss/3.0/default/Android.bp b/gnss/3.0/default/Android.bp
index 2b33b32..bb3c467 100644
--- a/gnss/3.0/default/Android.bp
+++ b/gnss/3.0/default/Android.bp
@@ -36,6 +36,7 @@
         "android.hardware.gnss@3.0",
         "android.hardware.gnss.measurement_corrections@1.1",
         "android.hardware.gnss.measurement_corrections@1.0",
+        "android.hardware.gnss-ndk_platform",
     ],
     static_libs: [
         "android.hardware.gnss@common-default-lib",
diff --git a/gnss/3.0/vts/functional/gnss_hal_test.h b/gnss/3.0/vts/functional/gnss_hal_test.h
index 387214e..be6d38c 100644
--- a/gnss/3.0/vts/functional/gnss_hal_test.h
+++ b/gnss/3.0/vts/functional/gnss_hal_test.h
@@ -19,7 +19,6 @@
 #include <android/hardware/gnss/3.0/IGnss.h>
 #include "v2_1/gnss_hal_test_template.h"
 
-using android::hardware::gnss::V3_0::IGnss;
-
 // The main test class for GNSS HAL.
-class GnssHalTest : public GnssHalTestTemplate<IGnss> {};
\ No newline at end of file
+class GnssHalTest : public android::hardware::gnss::common::GnssHalTestTemplate<
+                            android::hardware::gnss::V3_0::IGnss> {};
\ No newline at end of file
diff --git a/gnss/aidl/aidl_api/android.hardware.gnss/current/android/hardware/gnss/ElapsedRealtime.aidl b/gnss/aidl/aidl_api/android.hardware.gnss/current/android/hardware/gnss/ElapsedRealtime.aidl
index 354c953..a0e8de4 100644
--- a/gnss/aidl/aidl_api/android.hardware.gnss/current/android/hardware/gnss/ElapsedRealtime.aidl
+++ b/gnss/aidl/aidl_api/android.hardware.gnss/current/android/hardware/gnss/ElapsedRealtime.aidl
@@ -21,4 +21,6 @@
   int flags;
   long timestampNs;
   double timeUncertaintyNs;
+  const int HAS_TIMESTAMP_NS = 1;
+  const int HAS_TIME_UNCERTAINTY_NS = 2;
 }
diff --git a/keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/Digest.aidl b/gnss/aidl/aidl_api/android.hardware.gnss/current/android/hardware/gnss/GnssClock.aidl
similarity index 63%
copy from keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/Digest.aidl
copy to gnss/aidl/aidl_api/android.hardware.gnss/current/android/hardware/gnss/GnssClock.aidl
index cc4d2fd..42b940e 100644
--- a/keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/Digest.aidl
+++ b/gnss/aidl/aidl_api/android.hardware.gnss/current/android/hardware/gnss/GnssClock.aidl
@@ -15,14 +15,25 @@
 // 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;
-@Backing(type="int") @VintfStability
-enum Digest {
-  NONE = 0,
-  MD5 = 1,
-  SHA1 = 2,
-  SHA_2_224 = 3,
-  SHA_2_256 = 4,
-  SHA_2_384 = 5,
-  SHA_2_512 = 6,
+package android.hardware.gnss;
+@VintfStability
+parcelable GnssClock {
+  int gnssClockFlags;
+  int leapSecond;
+  long timeNs;
+  double timeUncertaintyNs;
+  long fullBiasNs;
+  double biasNs;
+  double biasUncertaintyNs;
+  double driftNsps;
+  double driftUncertaintyNsps;
+  int hwClockDiscontinuityCount;
+  android.hardware.gnss.GnssSignalType referenceSignalTypeForIsb;
+  const int HAS_LEAP_SECOND = 1;
+  const int HAS_TIME_UNCERTAINTY = 2;
+  const int HAS_FULL_BIAS = 4;
+  const int HAS_BIAS = 8;
+  const int HAS_BIAS_UNCERTAINTY = 16;
+  const int HAS_DRIFT = 32;
+  const int HAS_DRIFT_UNCERTAINTY = 64;
 }
diff --git a/keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/Certificate.aidl b/gnss/aidl/aidl_api/android.hardware.gnss/current/android/hardware/gnss/GnssData.aidl
similarity index 83%
copy from keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/Certificate.aidl
copy to gnss/aidl/aidl_api/android.hardware.gnss/current/android/hardware/gnss/GnssData.aidl
index ca55054..7ffabd2 100644
--- a/keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/Certificate.aidl
+++ b/gnss/aidl/aidl_api/android.hardware.gnss/current/android/hardware/gnss/GnssData.aidl
@@ -15,8 +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.gnss;
 @VintfStability
-parcelable Certificate {
-  byte[] encodedCertificate;
+parcelable GnssData {
+  android.hardware.gnss.GnssMeasurement[] measurements;
+  android.hardware.gnss.GnssClock clock;
+  android.hardware.gnss.ElapsedRealtime elapsedRealtime;
 }
diff --git a/gnss/aidl/aidl_api/android.hardware.gnss/current/android/hardware/gnss/GnssMeasurement.aidl b/gnss/aidl/aidl_api/android.hardware.gnss/current/android/hardware/gnss/GnssMeasurement.aidl
new file mode 100644
index 0000000..73d8a86
--- /dev/null
+++ b/gnss/aidl/aidl_api/android.hardware.gnss/current/android/hardware/gnss/GnssMeasurement.aidl
@@ -0,0 +1,78 @@
+///////////////////////////////////////////////////////////////////////////////
+// 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.gnss;
+@VintfStability
+parcelable GnssMeasurement {
+  int flags;
+  int svid;
+  android.hardware.gnss.GnssSignalType signalType;
+  double timeOffsetNs;
+  int state;
+  long receivedSvTimeInNs;
+  long receivedSvTimeUncertaintyInNs;
+  double antennaCN0DbHz;
+  double basebandCN0DbHz;
+  double pseudorangeRateMps;
+  double pseudorangeRateUncertaintyMps;
+  int accumulatedDeltaRangeState;
+  double accumulatedDeltaRangeM;
+  double accumulatedDeltaRangeUncertaintyM;
+  long carrierCycles;
+  double carrierPhase;
+  double carrierPhaseUncertainty;
+  android.hardware.gnss.GnssMultipathIndicator multipathIndicator;
+  double snrDb;
+  double agcLevelDb;
+  double fullInterSignalBiasNs;
+  double fullInterSignalBiasUncertaintyNs;
+  double satelliteInterSignalBiasNs;
+  double satelliteInterSignalBiasUncertaintyNs;
+  const int HAS_SNR = 1;
+  const int HAS_CARRIER_FREQUENCY = 512;
+  const int HAS_CARRIER_CYCLES = 1024;
+  const int HAS_CARRIER_PHASE = 2048;
+  const int HAS_CARRIER_PHASE_UNCERTAINTY = 4096;
+  const int HAS_AUTOMATIC_GAIN_CONTROL = 8192;
+  const int HAS_FULL_ISB = 65536;
+  const int HAS_FULL_ISB_UNCERTAINTY = 131072;
+  const int HAS_SATELLITE_ISB = 262144;
+  const int HAS_SATELLITE_ISB_UNCERTAINTY = 524288;
+  const int STATE_UNKNOWN = 0;
+  const int STATE_CODE_LOCK = 1;
+  const int STATE_BIT_SYNC = 2;
+  const int STATE_SUBFRAME_SYNC = 4;
+  const int STATE_TOW_DECODED = 8;
+  const int STATE_MSEC_AMBIGUOUS = 16;
+  const int STATE_SYMBOL_SYNC = 32;
+  const int STATE_GLO_STRING_SYNC = 64;
+  const int STATE_GLO_TOD_DECODED = 128;
+  const int STATE_BDS_D2_BIT_SYNC = 256;
+  const int STATE_BDS_D2_SUBFRAME_SYNC = 512;
+  const int STATE_GAL_E1BC_CODE_LOCK = 1024;
+  const int STATE_GAL_E1C_2ND_CODE_LOCK = 2048;
+  const int STATE_GAL_E1B_PAGE_SYNC = 4096;
+  const int STATE_SBAS_SYNC = 8192;
+  const int STATE_TOW_KNOWN = 16384;
+  const int STATE_GLO_TOD_KNOWN = 32768;
+  const int STATE_2ND_CODE_LOCK = 65536;
+  const int ADR_STATE_UNKNOWN = 0;
+  const int ADR_STATE_VALID = 1;
+  const int ADR_STATE_RESET = 2;
+  const int ADR_STATE_CYCLE_SLIP = 4;
+  const int ADR_STATE_HALF_CYCLE_RESOLVED = 8;
+}
diff --git a/keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/EcCurve.aidl b/gnss/aidl/aidl_api/android.hardware.gnss/current/android/hardware/gnss/GnssMultipathIndicator.aidl
similarity index 89%
copy from keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/EcCurve.aidl
copy to gnss/aidl/aidl_api/android.hardware.gnss/current/android/hardware/gnss/GnssMultipathIndicator.aidl
index 4e446ad..75ca3af 100644
--- a/keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/EcCurve.aidl
+++ b/gnss/aidl/aidl_api/android.hardware.gnss/current/android/hardware/gnss/GnssMultipathIndicator.aidl
@@ -15,11 +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.gnss;
 @Backing(type="int") @VintfStability
-enum EcCurve {
-  P_224 = 0,
-  P_256 = 1,
-  P_384 = 2,
-  P_521 = 3,
+enum GnssMultipathIndicator {
+  UNKNOWN = 0,
+  PRESENT = 1,
+  NOT_PRESENT = 2,
 }
diff --git a/gnss/aidl/aidl_api/android.hardware.gnss/current/android/hardware/gnss/GnssSignalType.aidl b/gnss/aidl/aidl_api/android.hardware.gnss/current/android/hardware/gnss/GnssSignalType.aidl
new file mode 100644
index 0000000..f10b943
--- /dev/null
+++ b/gnss/aidl/aidl_api/android.hardware.gnss/current/android/hardware/gnss/GnssSignalType.aidl
@@ -0,0 +1,40 @@
+///////////////////////////////////////////////////////////////////////////////
+// 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.gnss;
+@VintfStability
+parcelable GnssSignalType {
+  android.hardware.gnss.GnssConstellationType constellation;
+  double carrierFrequencyHz;
+  @utf8InCpp String codeType;
+  const @utf8InCpp String CODE_TYPE_A = "A";
+  const @utf8InCpp String CODE_TYPE_B = "B";
+  const @utf8InCpp String CODE_TYPE_C = "C";
+  const @utf8InCpp String CODE_TYPE_D = "D";
+  const @utf8InCpp String CODE_TYPE_I = "I";
+  const @utf8InCpp String CODE_TYPE_L = "L";
+  const @utf8InCpp String CODE_TYPE_M = "M";
+  const @utf8InCpp String CODE_TYPE_N = "N";
+  const @utf8InCpp String CODE_TYPE_P = "P";
+  const @utf8InCpp String CODE_TYPE_Q = "Q";
+  const @utf8InCpp String CODE_TYPE_S = "S";
+  const @utf8InCpp String CODE_TYPE_W = "W";
+  const @utf8InCpp String CODE_TYPE_X = "X";
+  const @utf8InCpp String CODE_TYPE_Y = "Y";
+  const @utf8InCpp String CODE_TYPE_Z = "Z";
+  const @utf8InCpp String CODE_TYPE_UNKNOWN = "UNKNOWN";
+}
diff --git a/gnss/aidl/aidl_api/android.hardware.gnss/current/android/hardware/gnss/IGnss.aidl b/gnss/aidl/aidl_api/android.hardware.gnss/current/android/hardware/gnss/IGnss.aidl
index e1a4b9e..10ac150 100644
--- a/gnss/aidl/aidl_api/android.hardware.gnss/current/android/hardware/gnss/IGnss.aidl
+++ b/gnss/aidl/aidl_api/android.hardware.gnss/current/android/hardware/gnss/IGnss.aidl
@@ -22,8 +22,7 @@
   void close();
   android.hardware.gnss.IGnssPsds getExtensionPsds();
   android.hardware.gnss.IGnssConfiguration getExtensionGnssConfiguration();
+  android.hardware.gnss.IGnssMeasurementInterface getExtensionGnssMeasurement();
   android.hardware.gnss.IGnssPowerIndication getExtensionGnssPowerIndication();
   const int ERROR_INVALID_ARGUMENT = 1;
-  const int ELAPSED_REALTIME_HAS_TIMESTAMP_NS = 1;
-  const int ELAPSED_REALTIME_HAS_TIME_UNCERTAINTY_NS = 2;
 }
diff --git a/keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/Certificate.aidl b/gnss/aidl/aidl_api/android.hardware.gnss/current/android/hardware/gnss/IGnssMeasurementCallback.aidl
similarity index 87%
copy from keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/Certificate.aidl
copy to gnss/aidl/aidl_api/android.hardware.gnss/current/android/hardware/gnss/IGnssMeasurementCallback.aidl
index ca55054..e05e9b9 100644
--- a/keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/Certificate.aidl
+++ b/gnss/aidl/aidl_api/android.hardware.gnss/current/android/hardware/gnss/IGnssMeasurementCallback.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.gnss;
 @VintfStability
-parcelable Certificate {
-  byte[] encodedCertificate;
+interface IGnssMeasurementCallback {
+  void gnssMeasurementCb(in android.hardware.gnss.GnssData data);
 }
diff --git a/keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/Certificate.aidl b/gnss/aidl/aidl_api/android.hardware.gnss/current/android/hardware/gnss/IGnssMeasurementInterface.aidl
similarity index 83%
copy from keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/Certificate.aidl
copy to gnss/aidl/aidl_api/android.hardware.gnss/current/android/hardware/gnss/IGnssMeasurementInterface.aidl
index ca55054..9576205 100644
--- a/keymint/aidl/aidl_api/android.hardware.keymint/current/android/hardware/keymint/Certificate.aidl
+++ b/gnss/aidl/aidl_api/android.hardware.gnss/current/android/hardware/gnss/IGnssMeasurementInterface.aidl
@@ -15,8 +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.gnss;
 @VintfStability
-parcelable Certificate {
-  byte[] encodedCertificate;
+interface IGnssMeasurementInterface {
+  void setCallback(in android.hardware.gnss.IGnssMeasurementCallback callback, in boolean enableFullTracking);
+  void close();
 }
diff --git a/gnss/aidl/android/hardware/gnss/ElapsedRealtime.aidl b/gnss/aidl/android/hardware/gnss/ElapsedRealtime.aidl
index fae14f8..67d090e 100644
--- a/gnss/aidl/android/hardware/gnss/ElapsedRealtime.aidl
+++ b/gnss/aidl/android/hardware/gnss/ElapsedRealtime.aidl
@@ -22,10 +22,18 @@
 @VintfStability
 parcelable ElapsedRealtime {
 
+    /** Bit mask indicating a valid timestampNs is stored in the ElapsedRealtime parcelable. */
+    const int HAS_TIMESTAMP_NS = 1 << 0;
+
+    /**
+     * Bit mask indicating a valid timeUncertaintyNs is stored in the ElapsedRealtime parcelable.
+     */
+    const int HAS_TIME_UNCERTAINTY_NS = 1 << 1;
+
     /**
      * A bit field of flags indicating the validity of each field in this data structure.
      *
-     * The bit masks are defined in IGnss interface and prefixed with ELAPSED_REALTIME_HAS_.
+     * The bit masks are the constants with prefix HAS_.
      *
      * Fields may have invalid information in them, if not marked as valid by the corresponding bit
      * in flags.
diff --git a/gnss/aidl/android/hardware/gnss/GnssClock.aidl b/gnss/aidl/android/hardware/gnss/GnssClock.aidl
new file mode 100644
index 0000000..f416e08
--- /dev/null
+++ b/gnss/aidl/android/hardware/gnss/GnssClock.aidl
@@ -0,0 +1,203 @@
+/*
+ * 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.
+ */
+
+package android.hardware.gnss;
+
+import android.hardware.gnss.GnssSignalType;
+
+/**
+ * Represents an estimate of the GNSS clock time.
+ */
+@VintfStability
+parcelable GnssClock {
+    /** Bit mask indicating a valid 'leap second' is stored in the GnssClock. */
+    const int HAS_LEAP_SECOND        = 1 << 0;
+    /** Bit mask indicating a valid 'time uncertainty' is stored in the GnssClock. */
+    const int HAS_TIME_UNCERTAINTY   = 1 << 1;
+    /** Bit mask indicating a valid 'full bias' is stored in the GnssClock. */
+    const int HAS_FULL_BIAS          = 1 << 2;
+    /** Bit mask indicating a valid 'bias' is stored in the GnssClock. */
+    const int HAS_BIAS               = 1 << 3;
+    /** Bit mask indicating a valid 'bias uncertainty' is stored in the GnssClock. */
+    const int HAS_BIAS_UNCERTAINTY   = 1 << 4;
+    /** Bit mask indicating a valid 'drift' is stored in the GnssClock. */
+    const int HAS_DRIFT              = 1 << 5;
+    /** Bit mask indicating a valid 'drift uncertainty' is stored in the GnssClock. */
+    const int HAS_DRIFT_UNCERTAINTY  = 1 << 6;
+
+    /**
+     * A bitfield of flags indicating the validity of the fields in this data
+     * structure.
+     *
+     * The bit masks are the constants with perfix HAS_.
+     *
+     * Fields for which there is no corresponding flag must be filled in
+     * with a valid value.  For convenience, these are marked as mandatory.
+     *
+     * Others fields may have invalid information in them, if not marked as
+     * valid by the corresponding bit in gnssClockFlags.
+     */
+    int gnssClockFlags;
+
+    /**
+     * Leap second data.
+     * The sign of the value is defined by the following equation:
+     *      utcTimeNs = timeNs - (fullBiasNs + biasNs) - leapSecond *
+     *      1,000,000,000
+     *
+     * If this data is available, gnssClockFlags must contain
+     * HAS_LEAP_SECOND.
+     */
+    int leapSecond;
+
+    /**
+     * The GNSS receiver internal clock value. This is the local hardware clock
+     * value.
+     *
+     * For local hardware clock, this value is expected to be monotonically
+     * increasing while the hardware clock remains powered on. (For the case of a
+     * HW clock that is not continuously on, see the
+     * hwClockDiscontinuityCount field). The receiver's estimate of GNSS time
+     * can be derived by subtracting the sum of fullBiasNs and biasNs (when
+     * available) from this value.
+     *
+     * This GNSS time must be the best estimate of current GNSS time
+     * that GNSS receiver can achieve.
+     *
+     * Sub-nanosecond accuracy can be provided by means of the 'biasNs' field.
+     * The value contains the timeUncertaintyNs in it.
+     *
+     * This value is mandatory.
+     */
+    long timeNs;
+
+    /**
+     * 1-Sigma uncertainty associated with the clock's time in nanoseconds.
+     * The uncertainty is represented as an absolute (single sided) value.
+     *
+     * If the data is available, gnssClockFlags must contain
+     * HAS_TIME_UNCERTAINTY. Ths value is ideally zero, as the time
+     * 'latched' by timeNs is defined as the reference clock vs. which all
+     * other times (and corresponding uncertainties) are measured.
+     */
+    double timeUncertaintyNs;
+
+    /**
+     * The difference between hardware clock ('time' field) inside GNSS receiver
+     * and the true GPS time since 0000Z, January 6, 1980, in nanoseconds.
+     *
+     * The sign of the value is defined by the following equation:
+     *      local estimate of GPS time = timeNs - (fullBiasNs + biasNs)
+     *
+     * If receiver has computed time for a non-GPS constellation, the time offset of
+     * that constellation versus GPS time must be applied to fill this value.
+     *
+     * The error estimate for the sum of this and the biasNs is the biasUncertaintyNs.
+     *
+     * If the data is available gnssClockFlags must contain HAS_FULL_BIAS.
+     *
+     * This value is mandatory if the receiver has estimated GPS time.
+     */
+    long fullBiasNs;
+
+    /**
+     * Sub-nanosecond bias - used with fullBiasNS, see fullBiasNs for details.
+     *
+     * The error estimate for the sum of this and the fullBiasNs is the
+     * biasUncertaintyNs.
+     *
+     * If the data is available gnssClockFlags must contain HAS_BIAS.
+     *
+     * This value is mandatory if the receiver has estimated GPS time.
+     */
+    double biasNs;
+
+    /**
+     * 1-Sigma uncertainty associated with the local estimate of GNSS time (clock
+     * bias) in nanoseconds. The uncertainty is represented as an absolute
+     * (single sided) value.
+     *
+     * The caller is responsible for using this uncertainty (it can be very
+     * large before the GPS time has been fully resolved.)
+     *
+     * If the data is available gnssClockFlags must contain HAS_BIAS_UNCERTAINTY.
+     *
+     * This value is mandatory if the receiver has estimated GPS time.
+     */
+    double biasUncertaintyNs;
+
+    /**
+     * The clock's drift in nanoseconds (per second).
+     *
+     * A positive value means that the frequency is higher than the nominal
+     * frequency, and that the (fullBiasNs + biasNs) is growing more positive
+     * over time.
+     *
+     * If the data is available gnssClockFlags must contain HAS_DRIFT.
+     *
+     * This value is mandatory if the receiver has estimated GPS time.
+     */
+    double driftNsps;
+
+    /**
+     * 1-Sigma uncertainty associated with the clock's drift in nanoseconds (per
+     * second).
+     * The uncertainty is represented as an absolute (single sided) value.
+     *
+     * If the data is available gnssClockFlags must contain HAS_DRIFT_UNCERTAINTY.
+     *
+     * This value is mandatory if the receiver has estimated GPS time.
+     */
+    double driftUncertaintyNsps;
+
+    /**
+     * This field must be incremented, when there are discontinuities in the
+     * hardware clock.
+     *
+     * A "discontinuity" is meant to cover the case of a switch from one source
+     * of clock to another.  A single free-running crystal oscillator (XO)
+     * will generally not have any discontinuities, and this can be set and
+     * left at 0.
+     *
+     * If, however, the timeNs value (HW clock) is derived from a composite of
+     * sources, that is not as smooth as a typical XO, or is otherwise stopped &
+     * restarted, then this value shall be incremented each time a discontinuity
+     * occurs.  (E.g. this value can start at zero at device boot-up and
+     * increment each time there is a change in clock continuity. In the
+     * unlikely event that this value reaches full scale, rollover (not
+     * clamping) is required, such that this value continues to change, during
+     * subsequent discontinuity events.)
+     *
+     * While this number stays the same, between GnssClock reports, it can be
+     * safely assumed that the timeNs value has been running continuously, e.g.
+     * derived from a single, high quality clock (XO like, or better, that is
+     * typically used during continuous GNSS signal sampling.)
+     *
+     * It is expected, esp. during periods where there are few GNSS signals
+     * available, that the HW clock be discontinuity-free as long as possible,
+     * as this avoids the need to use (waste) a GNSS measurement to fully
+     * re-solve for the GNSS clock bias and drift, when using the accompanying
+     * measurements, from consecutive GnssData reports.
+     *
+     * This value is mandatory.
+     */
+    int hwClockDiscontinuityCount;
+
+    /**
+     * Reference GNSS signal type for inter-signal bias.
+     */
+    GnssSignalType referenceSignalTypeForIsb;
+}
\ No newline at end of file
diff --git a/gnss/aidl/android/hardware/gnss/GnssData.aidl b/gnss/aidl/android/hardware/gnss/GnssData.aidl
new file mode 100644
index 0000000..ed30c98
--- /dev/null
+++ b/gnss/aidl/android/hardware/gnss/GnssData.aidl
@@ -0,0 +1,44 @@
+/*
+ * 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.
+ */
+
+package android.hardware.gnss;
+
+import android.hardware.gnss.ElapsedRealtime;
+import android.hardware.gnss.GnssClock;
+import android.hardware.gnss.GnssMeasurement;
+
+/**
+ * Represents a reading of GNSS measurements. For devices launched in Android Q or newer, it is
+ * mandatory that these be provided, on request, when the GNSS receiver is searching/tracking
+ * signals.
+ *
+ * - Reporting of GNSS constellation measurements is mandatory.
+ * - Reporting of all tracked constellations are encouraged.
+ */
+@VintfStability
+parcelable GnssData {
+    /** The array of measurements. */
+    GnssMeasurement[] measurements;
+
+    /** The GNSS clock time reading. */
+    GnssClock clock;
+
+    /**
+     * Timing information of the GNSS data synchronized with SystemClock.elapsedRealtimeNanos()
+     * clock.
+     */
+    ElapsedRealtime elapsedRealtime;
+}
\ No newline at end of file
diff --git a/gnss/aidl/android/hardware/gnss/GnssMeasurement.aidl b/gnss/aidl/android/hardware/gnss/GnssMeasurement.aidl
new file mode 100644
index 0000000..ce88647
--- /dev/null
+++ b/gnss/aidl/android/hardware/gnss/GnssMeasurement.aidl
@@ -0,0 +1,615 @@
+/*
+ * 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.
+ */
+
+package android.hardware.gnss;
+
+import android.hardware.gnss.GnssSignalType;
+import android.hardware.gnss.GnssMultipathIndicator;
+
+/**
+ * Represents a GNSS Measurement, it contains raw and computed information.
+ *
+ * All signal measurement information (e.g. svTime, pseudorangeRate, multipathIndicator) reported in
+ * this struct must be based on GNSS signal measurements only. You must not synthesize measurements
+ * by calculating or reporting expected measurements based on known or estimated position, velocity,
+ * or time.
+ */
+@VintfStability
+parcelable GnssMeasurement {
+    /** Bit mask indicating a valid 'snr' is stored in the GnssMeasurement. */
+    const int HAS_SNR                        = 1 << 0;
+    /** Bit mask indicating a valid 'carrier frequency' is stored in the GnssMeasurement. */
+    const int HAS_CARRIER_FREQUENCY          = 1 << 9;
+    /** Bit mask indicating a valid 'carrier cycles' is stored in the GnssMeasurement. */
+    const int HAS_CARRIER_CYCLES             = 1 << 10;
+    /** Bit mask indicating a valid 'carrier phase' is stored in the GnssMeasurement. */
+    const int HAS_CARRIER_PHASE              = 1 << 11;
+    /** Bit mask indicating a valid 'carrier phase uncertainty' is stored in the GnssMeasurement. */
+    const int HAS_CARRIER_PHASE_UNCERTAINTY  = 1 << 12;
+    /** Bit mask indicating a valid automatic gain control is stored in the GnssMeasurement. */
+    const int HAS_AUTOMATIC_GAIN_CONTROL     = 1 << 13;
+    /** Bit mask indicating a valid full inter-signal bias is stored in the GnssMeasurement. */
+    const int HAS_FULL_ISB                   = 1 << 16;
+    /**
+     * Bit mask indicating a valid full inter-signal bias uncertainty is stored in the
+     * GnssMeasurement.
+     */
+    const int HAS_FULL_ISB_UNCERTAINTY       = 1 << 17;
+    /**
+     * Bit mask indicating a valid satellite inter-signal bias is stored in the GnssMeasurement.
+     */
+    const int HAS_SATELLITE_ISB              = 1 << 18;
+    /**
+     * Bit mask indicating a valid satellite inter-signal bias uncertainty is stored in the
+     * GnssMeasurement.
+     */
+    const int HAS_SATELLITE_ISB_UNCERTAINTY  = 1 << 19;
+
+    /**
+     * A bitfield of flags indicating the validity of the fields in this GnssMeasurement. The bit
+     * masks are defined in the constants with prefix HAS_*
+     *
+     * Fields for which there is no corresponding flag must be filled in with a valid value.  For
+     * convenience, these are marked as mandatory.
+     *
+     * Others fields may have invalid information in them, if not marked as valid by the
+     * corresponding bit in flags.
+     */
+    int flags;
+
+    /**
+     * Satellite vehicle ID number, as defined in GnssSvInfo::svid
+     *
+     * This value is mandatory.
+     */
+    int svid;
+
+    /**
+     * Defines the constellation of the given SV.
+     *
+     * This value is mandatory.
+     */
+    GnssSignalType signalType;
+
+    /**
+     * Time offset at which the measurement was taken in nanoseconds.
+     * The reference receiver's time is specified by GnssData::clock::timeNs.
+     *
+     * The sign of timeOffsetNs is given by the following equation:
+     *      measurement time = GnssClock::timeNs + timeOffsetNs
+     *
+     * It provides an individual time-stamp for the measurement, and allows
+     * sub-nanosecond accuracy. It may be zero if all measurements are
+     * aligned to a common time.
+     *
+     * This value is mandatory.
+     */
+    double timeOffsetNs;
+
+    /**
+     * Flags indicating the GNSS measurement state.
+     *
+     * The expected behavior here is for GNSS HAL to set all the flags that apply. For example, if
+     * the state for a satellite is only C/A code locked and bit synchronized, and there is still
+     * millisecond ambiguity, the state must be set as:
+     *
+     * STATE_CODE_LOCK | STATE_BIT_SYNC |  STATE_MSEC_AMBIGUOUS
+     *
+     * If GNSS is still searching for a satellite, the corresponding state must be set to
+     * STATE_UNKNOWN(0).
+     *
+     * The received satellite time is relative to the beginning of the system week for all
+     * constellations except for Glonass where it is relative to the beginning of the Glonass system
+     * day.
+     *
+     * The table below indicates the valid range of the received GNSS satellite time.  These ranges
+     * depend on the constellation and code being tracked and the state of the tracking algorithms
+     * given by the getState method. If the state flag is set, then the valid measurement range is
+     * zero to the value in the table. The state flag with the widest range indicates the range of
+     * the received GNSS satellite time value.
+     *
+     * +---------------------------+--------------------+-----+-----------+--------------------+------+
+     * |                           |GPS/QZSS	        |GLNS |BDS        |GAL                 |SBAS  |
+     * +---------------------------+------+------+------+-----+------+----+------+------+------+------+
+     * |State Flag	               |L1    |L5I   |L5Q   |L1OF |B1I   |B1I |E1B   |E1C   |E5AQ  |L1    |
+     * |                           |C/A	  |      |      |     |(D1)  |(D2)|      |      |      |C/A   |
+     * |---------------------------+------+------+------+-----+------+----+------+------+------+------+
+     * |STATE_UNKNOWN              |0	  |0	 |0	    |0	  |0	 |0   |0     |0     |0	   |0     |
+     * |---------------------------+------+------+------+-----+------+----+------+------+------+------+
+     * |STATE_CODE_LOCK            |1ms   |1 ms  |1 ms  |1 ms |1 ms  |1 ms|-     |-     |1 ms  |1 ms  |
+     * |---------------------------+------+------+------+-----+------+----+------+------+------+------+
+     * |STATE_SYMBOL_SYNC          |20ms  |10 ms |1 ms  |10 ms|20 ms |2 ms|4 ms  |4 ms  |1 ms  |2 ms  |
+     * |                           |(opt.)|	     |(opt.)|     |(opt.)|    |(opt.)|(opt.)|(opt.)|      |
+     * |---------------------------+------+------+------+-----+------+----+------+------+------+------+
+     * |STATE_BIT_SYNC             |20 ms |20 ms |1 ms  |20 ms|20 ms |-   |8 ms  |-     |1 ms  |4 ms  |
+     * |                           |      |      |(opt.)|     |      |    |      |      |(opt.)|      |
+     * |---------------------------+------+------+------+-----+------+----+------+------+------+------+
+     * |STATE_SUBFRAME_SYNC        |6s    |6s    |-     |2 s  |6 s   |-   |-     |-     |100 ms|-     |
+     * |---------------------------+------+------+------+-----+------+----+------+------+------+------+
+     * |STATE_TOW_DECODED          |1 week|-     |-     |1 day|1 week|-   |1 week|-     |-     |1 week|
+     * |---------------------------+------+------+------+-----+------+----+------+------+------+------+
+     * |STATE_TOW_KNOWN            |1 week|-     |-     |1 day|1 week|-   |1 week|-     |-     |1 week|
+     * |---------------------------+------+------+------+-----+------+----+------+------+------+------+
+     * |STATE_GLO_STRING_SYNC      |-     |-     |-     |2 s  |-     |-   |-     |-     |-     |-     |
+     * |---------------------------+------+------+------+-----+------+----+------+------+------+------+
+     * |STATE_GLO_TOD_DECODED      |-     |-     |-     |1 day|-     |-   |-     |-     |-     |-     |
+     * |---------------------------+------+------+------+-----+------+----+------+------+------+------+
+     * |STATE_GLO_TOD_KNOWN        |-     |-     |-     |1 day|-     |-   |-     |-     |-     |-     |
+     * |---------------------------+------+------+------+-----+------+----+------+------+------+------+
+     * |STATE_BDS_D2_BIT_SYNC      |-     |-     |-     |-    |-     |2 ms|-     |-     |-     |-     |
+     * |---------------------------+------+------+------+-----+------+----+------+------+------+------+
+     * |STATE_BDS_D2_SUBFRAME_SYNC |-     |-     |-     |-    |-     |600 |-     |-     |-     |-     |
+     * |                           |      |      |      |     |      |ms  |      |      |      |      |
+     * |---------------------------+------+------+------+-----+------+----+------+------+------+------+
+     * |STATE_GAL_E1BC_CODE_LOCK   |-     |-     |-     |-    |-     |-   |4 ms  |4 ms  |-     |-     |
+     * |---------------------------+------+------+------+-----+------+----+------+------+------+------+
+     * |STATE_GAL_E1C_2ND_CODE_LOCK|-     |-     |-     |-    |-     |-   |-     |100 ms|-     |-     |
+     * |---------------------------+------+------+------+-----+------+----+------+------+------+------+
+     * |STATE_2ND_CODE_LOCK        |-     |10 ms |20 ms |-    |-     |-	  |-     |100 ms|100 ms|-     |
+     * |                           |      |(opt.)|      |     |      |    |      |(opt.)|      |      |
+     * |---------------------------+------+------+------+-----+------+----+------+------+------+------+
+     * |STATE_GAL_E1B_PAGE_SYNC    |-     |-     |-     |-    |-     |-   |2 s   |-     |-     |-     |
+     * |---------------------------+------+------+------+-----+------+----+------+------+------+------+
+     * |STATE_SBAS_SYNC            |-     |-     |-     |-    |-     |-   |-     |-     |-     |1s    |
+     * +---------------------------+------+------+------+-----+------+----+------+------+------+------+
+     *
+     * Note: TOW Known refers to the case where TOW is possibly not decoded over the air but has
+     * been determined from other sources. If TOW decoded is set then TOW Known must also be set.
+     *
+     * Note well: if there is any ambiguity in integer millisecond, STATE_MSEC_AMBIGUOUS must be
+     * set accordingly, in the 'state' field.  This value must be populated if 'state' !=
+     * STATE_UNKNOWN.
+     *
+     * Note on optional flags:
+     *   - For L1 C/A and B1I, STATE_SYMBOL_SYNC is optional since the symbol length is the
+     *     same as the bit length.
+     *   - For L5Q and E5aQ, STATE_BIT_SYNC and STATE_SYMBOL_SYNC are optional since they are
+     *     implied by STATE_CODE_LOCK.
+     *   - STATE_2ND_CODE_LOCK for L5I is optional since it is implied by STATE_SYMBOL_SYNC.
+     *   - STATE_2ND_CODE_LOCK for E1C is optional since it is implied by
+     *     STATE_GAL_E1C_2ND_CODE_LOCK.
+     *   - For E1B and E1C, STATE_SYMBOL_SYNC is optional, because it is implied by
+     *     STATE_GAL_E1BC_CODE_LOCK.
+     */
+    const int STATE_UNKNOWN                = 0;
+    const int STATE_CODE_LOCK              = 1 << 0;
+    const int STATE_BIT_SYNC               = 1 << 1;
+    const int STATE_SUBFRAME_SYNC          = 1 << 2;
+    const int STATE_TOW_DECODED            = 1 << 3;
+    const int STATE_MSEC_AMBIGUOUS         = 1 << 4;
+    const int STATE_SYMBOL_SYNC            = 1 << 5;
+    const int STATE_GLO_STRING_SYNC        = 1 << 6;
+    const int STATE_GLO_TOD_DECODED        = 1 << 7;
+    const int STATE_BDS_D2_BIT_SYNC        = 1 << 8;
+    const int STATE_BDS_D2_SUBFRAME_SYNC   = 1 << 9;
+    const int STATE_GAL_E1BC_CODE_LOCK     = 1 << 10;
+    const int STATE_GAL_E1C_2ND_CODE_LOCK  = 1 << 11;
+    const int STATE_GAL_E1B_PAGE_SYNC      = 1 << 12;
+    const int STATE_SBAS_SYNC              = 1 << 13;
+    const int STATE_TOW_KNOWN              = 1 << 14;
+    const int STATE_GLO_TOD_KNOWN          = 1 << 15;
+    const int STATE_2ND_CODE_LOCK          = 1 << 16;
+
+    /**
+     * A bitfield of flags indicating the GnssMeasurementState per satellite sync state. It
+     * represents the current sync state for the associated satellite.
+     *
+     * Based on the sync state, the 'received GNSS tow' field must be interpreted accordingly.
+     *
+     * The bit masks are defined in the constants with prefix STATE_.
+     *
+     * This value is mandatory.
+     */
+    int state;
+
+    /**
+     * The received GNSS Time-of-Week at the measurement time, in nanoseconds.
+     * For GNSS & QZSS, this is the received GNSS Time-of-Week at the
+     * measurement time, in nanoseconds. The value is relative to the
+     * beginning of the current GNSS week.
+     *
+     * Given the highest sync state that can be achieved, per each satellite,
+     * valid range for this field can be:
+     * Searching       : [ 0       ] : STATE_UNKNOWN
+     * C/A code lock   : [ 0 1ms   ] : STATE_CODE_LOCK set
+     * Bit sync        : [ 0 20ms  ] : STATE_BIT_SYNC set
+     * Subframe sync   : [ 0  6s   ] : STATE_SUBFRAME_SYNC set
+     * TOW decoded     : [ 0 1week ] : STATE_TOW_DECODED set
+     * TOW Known       : [ 0 1week ] : STATE_TOW_KNOWN set
+     *
+     * Note: TOW Known refers to the case where TOW is possibly not decoded
+     * over the air but has been determined from other sources. If TOW
+     * decoded is set then TOW Known must also be set.
+     *
+     * Note: If there is any ambiguity in integer millisecond,
+     * STATE_MSEC_AMBIGUOUS must be set accordingly, in the
+     * 'state' field.
+     *
+     * This value must be populated if 'state' != STATE_UNKNOWN.
+     *
+     * For Glonass, this is the received Glonass time of day, at the
+     * measurement time in nanoseconds.
+     *
+     * Given the highest sync state that can be achieved, per each satellite,
+     * valid range for this field can be:
+     * Searching           : [ 0       ] : STATE_UNKNOWN set
+     * C/A code lock       : [ 0   1ms ] : STATE_CODE_LOCK set
+     * Symbol sync         : [ 0  10ms ] : STATE_SYMBOL_SYNC set
+     * Bit sync            : [ 0  20ms ] : STATE_BIT_SYNC set
+     * String sync         : [ 0    2s ] : STATE_GLO_STRING_SYNC set
+     * Time of day decoded : [ 0  1day ] : STATE_GLO_TOD_DECODED set
+     * Time of day known   : [ 0  1day ] : STATE_GLO_TOD_KNOWN set
+     *
+     * Note: Time of day known refers to the case where it is possibly not
+     * decoded over the air but has been determined from other sources. If
+     * Time of day decoded is set then Time of day known must also be set.
+     *
+     * For Beidou, this is the received Beidou time of week,
+     * at the measurement time in nanoseconds.
+     *
+     * Given the highest sync state that can be achieved, per each satellite,
+     * valid range for this field can be:
+     * Searching            : [ 0       ] : STATE_UNKNOWN set.
+     * C/A code lock        : [ 0   1ms ] : STATE_CODE_LOCK set.
+     * Bit sync (D2)        : [ 0   2ms ] : STATE_BDS_D2_BIT_SYNC set.
+     * Bit sync (D1)        : [ 0  20ms ] : STATE_BIT_SYNC set.
+     * Subframe (D2)        : [ 0  0.6s ] : STATE_BDS_D2_SUBFRAME_SYNC set.
+     * Subframe (D1)        : [ 0    6s ] : STATE_SUBFRAME_SYNC set.
+     * Time of week decoded : [ 0 1week ] : STATE_TOW_DECODED set.
+     * Time of week known   : [ 0 1week ] : STATE_TOW_KNOWN set
+     *
+     * Note: TOW Known refers to the case where TOW is possibly not decoded
+     * over the air but has been determined from other sources. If TOW
+     * decoded is set then TOW Known must also be set.
+     *
+     * For Galileo, this is the received Galileo time of week,
+     * at the measurement time in nanoseconds.
+     *
+     * E1BC code lock       : [ 0  4ms ] : STATE_GAL_E1BC_CODE_LOCK set.
+     * E1C 2nd code lock    : [ 0 100ms] : STATE_GAL_E1C_2ND_CODE_LOCK set.
+     * E1B page             : [ 0   2s ] : STATE_GAL_E1B_PAGE_SYNC set.
+     * Time of week decoded : [ 0 1week] : STATE_TOW_DECODED is set.
+     * Time of week known   : [ 0 1week] : STATE_TOW_KNOWN set
+     *
+     * Note: TOW Known refers to the case where TOW is possibly not decoded
+     * over the air but has been determined from other sources. If TOW
+     * decoded is set then TOW Known must also be set.
+     *
+     * For SBAS, this is received SBAS time, at the measurement time in
+     * nanoseconds.
+     *
+     * Given the highest sync state that can be achieved, per each satellite,
+     * valid range for this field can be:
+     * Searching    : [ 0     ] : STATE_UNKNOWN
+     * C/A code lock: [ 0 1ms ] : STATE_CODE_LOCK is set
+     * Symbol sync  : [ 0 2ms ] : STATE_SYMBOL_SYNC is set
+     * Message      : [ 0  1s ] : STATE_SBAS_SYNC is set
+     */
+    long receivedSvTimeInNs;
+
+    /**
+     * 1-Sigma uncertainty of the Received GNSS Time-of-Week in nanoseconds.
+     *
+     * This value must be populated if 'state' != STATE_UNKNOWN.
+     */
+    long receivedSvTimeUncertaintyInNs;
+
+    /**
+     * Carrier-to-noise density in dB-Hz, typically in the range [0, 63].
+     * It contains the measured C/N0 value for the signal at the antenna port.
+     *
+     * If a signal has separate components (e.g. Pilot and Data channels) and
+     * the receiver only processes one of the components, then the reported
+     * antennaCN0DbHz reflects only the component that is processed.
+     *
+     * This value is mandatory.
+     */
+    double antennaCN0DbHz;
+
+    /**
+     * Baseband Carrier-to-noise density in dB-Hz, typically in the range [0, 63]. It contains the
+     * measured C/N0 value for the signal measured at the baseband.
+     *
+     * This is typically a few dB weaker than the value estimated for C/N0 at the antenna port,
+     * which is reported in cN0DbHz.
+     *
+     * If a signal has separate components (e.g. Pilot and Data channels) and the receiver only
+     * processes one of the components, then the reported basebandCN0DbHz reflects only the
+     * component that is processed.
+     *
+     * This value is mandatory.
+     */
+    double basebandCN0DbHz;
+
+    /**
+     * Pseudorange rate at the timestamp in m/s. The correction of a given
+     * Pseudorange Rate value includes corrections for receiver and satellite
+     * clock frequency errors. Ensure that this field is independent (see
+     * comment at top of GnssMeasurement struct.)
+     *
+     * It is mandatory to provide the 'uncorrected' 'pseudorange rate', and
+     * provide GnssClock's 'drift' field as well. When providing the
+     * uncorrected pseudorange rate, do not apply the corrections described above.)
+     *
+     * The value includes the 'pseudorange rate uncertainty' in it.
+     * A positive 'uncorrected' value indicates that the SV is moving away from
+     * the receiver.
+     *
+     * The sign of the 'uncorrected' 'pseudorange rate' and its relation to the
+     * sign of 'doppler shift' is given by the equation:
+     *      pseudorange rate = -k * doppler shift   (where k is a constant)
+     *
+     * This must be the most accurate pseudorange rate available, based on
+     * fresh signal measurements from this channel.
+     *
+     * It is mandatory that this value be provided at typical carrier phase PRR
+     * quality (few cm/sec per second of uncertainty, or better) - when signals
+     * are sufficiently strong & stable, e.g. signals from a GNSS simulator at >=
+     * 35 dB-Hz.
+     */
+    double pseudorangeRateMps;
+
+    /**
+     * 1-Sigma uncertainty of the pseudorangeRateMps.
+     * The uncertainty is represented as an absolute (single sided) value.
+     *
+     * This value is mandatory.
+     */
+    double pseudorangeRateUncertaintyMps;
+
+
+    /**
+     * Flags indicating the Accumulated Delta Range's states.
+     *
+     * See the table below for a detailed interpretation of each state.
+     *
+     * +---------------------+-------------------+-----------------------------+
+     * | ADR_STATE           | Time of relevance | Interpretation              |
+     * +---------------------+-------------------+-----------------------------+
+     * | UNKNOWN             | ADR(t)            | No valid carrier phase      |
+     * |                     |                   | information is available    |
+     * |                     |                   | at time t.                  |
+     * +---------------------+-------------------+-----------------------------+
+     * | VALID               | ADR(t)            | Valid carrier phase         |
+     * |                     |                   | information is available    |
+     * |                     |                   | at time t. This indicates   |
+     * |                     |                   | that this measurement can   |
+     * |                     |                   | be used as a reference for  |
+     * |                     |                   | future measurements.        |
+     * |                     |                   | However, to compare it to   |
+     * |                     |                   | previous measurements to    |
+     * |                     |                   | compute delta range,        |
+     * |                     |                   | other bits should be        |
+     * |                     |                   | checked. Specifically, it   |
+     * |                     |                   | can be used for delta range |
+     * |                     |                   | computation if it is valid  |
+     * |                     |                   | and has no reset or cycle   |
+     * |                     |                   | slip at this epoch i.e.     |
+     * |                     |                   | if VALID_BIT == 1 &&        |
+     * |                     |                   | CYCLE_SLIP_BIT == 0 &&      |
+     * |                     |                   | RESET_BIT == 0.             |
+     * +---------------------+-------------------+-----------------------------+
+     * | RESET               | ADR(t) - ADR(t-1) | Carrier phase accumulation  |
+     * |                     |                   | has been restarted between  |
+     * |                     |                   | current time t and previous |
+     * |                     |                   | time t-1. This indicates    |
+     * |                     |                   | that this measurement can   |
+     * |                     |                   | be used as a reference for  |
+     * |                     |                   | future measurements, but it |
+     * |                     |                   | should not be compared to   |
+     * |                     |                   | previous measurements to    |
+     * |                     |                   | compute delta range.        |
+     * +---------------------+-------------------+-----------------------------+
+     * | CYCLE_SLIP          | ADR(t) - ADR(t-1) | Cycle slip(s) have been     |
+     * |                     |                   | detected between the        |
+     * |                     |                   | current time t and previous |
+     * |                     |                   | time t-1. This indicates    |
+     * |                     |                   | that this measurement can   |
+     * |                     |                   | be used as a reference for  |
+     * |                     |                   | future measurements.        |
+     * |                     |                   | Clients can use a           |
+     * |                     |                   | measurement with a cycle    |
+     * |                     |                   | slip to compute delta range |
+     * |                     |                   | against previous            |
+     * |                     |                   | measurements at their own   |
+     * |                     |                   | risk.                       |
+     * +---------------------+-------------------+-----------------------------+
+     * | HALF_CYCLE_RESOLVED | ADR(t)            | Half cycle ambiguity is     |
+     * |                     |                   | resolved at time t.         |
+     * +---------------------+-------------------+-----------------------------+
+     */
+    const int ADR_STATE_UNKNOWN = 0;
+    const int ADR_STATE_VALID = 1 << 0;
+    const int ADR_STATE_RESET = 1 << 1;
+    const int ADR_STATE_CYCLE_SLIP = 1 << 2;
+    const int ADR_STATE_HALF_CYCLE_RESOLVED = 1 << 3;
+
+    /**
+     * A bitfield of flags indicating the accumulated delta range's state. It indicates whether ADR
+     * is reset or there is a cycle slip(indicating loss of lock).
+     *
+     * The bit masks are defined in constants with prefix ADR_STATE_.
+     *
+     * This value is mandatory.
+     */
+    int accumulatedDeltaRangeState;
+
+    /**
+     * Accumulated delta range since the last channel reset in meters.
+     * A positive value indicates that the SV is moving away from the receiver.
+     *
+     * The sign of the 'accumulated delta range' and its relation to the sign of
+     * 'carrier phase' is given by the equation:
+     * accumulated delta range = -k * carrier phase (where k is a constant)
+     *
+     * This value must be populated if 'accumulated delta range state' !=
+     * ADR_STATE_UNKNOWN.
+     * However, it is expected that the data is only accurate when:
+     *      'accumulated delta range state' == ADR_STATE_VALID.
+     *
+     * The alignment of the phase measurement will not be  adjusted by the receiver so the in-phase
+     * and quadrature phase components will have a quarter cycle offset as they do when transmitted
+     * from the satellites. If the measurement is from a combination of the in-phase and quadrature
+     * phase components, then the alignment of the phase measurement will be aligned to the in-phase
+     * component.
+     */
+    double accumulatedDeltaRangeM;
+
+    /**
+     * 1-Sigma uncertainty of the accumulated delta range in meters.
+     * This value must be populated if 'accumulated delta range state' !=
+     * ADR_STATE_UNKNOWN.
+     */
+    double accumulatedDeltaRangeUncertaintyM;
+
+    /**
+     * The number of full carrier cycles between the satellite and the
+     * receiver. The reference frequency is given by the field
+     * 'carrierFrequencyHz'. Indications of possible cycle slips and
+     * resets in the accumulation of this value can be inferred from the
+     * accumulatedDeltaRangeState flags.
+     *
+     * If the data is available, gnssMeasurementFlags must contain
+     * HAS_CARRIER_CYCLES.
+     */
+    long carrierCycles;
+
+    /**
+     * The RF phase detected by the receiver, in the range [0.0, 1.0].
+     * This is usually the fractional part of the complete carrier phase
+     * measurement.
+     *
+     * The reference frequency is given by the field 'carrierFrequencyHz'.
+     * The value contains the 'carrier-phase uncertainty' in it.
+     *
+     * If the data is available, gnssMeasurementFlags must contain
+     * HAS_CARRIER_PHASE.
+     */
+    double carrierPhase;
+
+    /**
+     * 1-Sigma uncertainty of the carrier-phase.
+     * If the data is available, gnssMeasurementFlags must contain
+     * HAS_CARRIER_PHASE_UNCERTAINTY.
+     */
+    double carrierPhaseUncertainty;
+
+    /**
+     * An enumeration that indicates the 'multipath' state of the event.
+     *
+     * The multipath Indicator is intended to report the presence of overlapping
+     * signals that manifest as distorted correlation peaks.
+     *
+     * - if there is a distorted correlation peak shape, report that multipath
+     *   is MULTIPATH_INDICATOR_PRESENT.
+     * - if there is no distorted correlation peak shape, report
+     *   MULTIPATH_INDICATOR_NOT_PRESENT
+     * - if signals are too weak to discern this information, report
+     *   MULTIPATH_INDICATOR_UNKNOWN
+     *
+     * Example: when doing the standardized overlapping Multipath Performance
+     * test (3GPP TS 34.171) the Multipath indicator must report
+     * MULTIPATH_INDICATOR_PRESENT for those signals that are tracked, and
+     * contain multipath, and MULTIPATH_INDICATOR_NOT_PRESENT for those
+     * signals that are tracked and do not contain multipath.
+     */
+    GnssMultipathIndicator multipathIndicator;
+
+    /**
+     * Signal-to-noise ratio at correlator output in dB.
+     * If the data is available, GnssMeasurementFlags must contain HAS_SNR.
+     * This is the power ratio of the "correlation peak height above the
+     * observed noise floor" to "the noise RMS".
+     */
+    double snrDb;
+
+    /**
+     * Automatic gain control (AGC) level. AGC acts as a variable gain
+     * amplifier adjusting the power of the incoming signal. The AGC level
+     * may be used to indicate potential interference. When AGC is at a
+     * nominal level, this value must be set as 0. Higher gain (and/or lower
+     * input power) must be output as a positive number. Hence in cases of
+     * strong jamming, in the band of this signal, this value must go more
+     * negative.
+     *
+     * Note: Different hardware designs (e.g. antenna, pre-amplification, or
+     * other RF HW components) may also affect the typical output of this
+     * value on any given hardware design in an open sky test - the
+     * important aspect of this output is that changes in this value are
+     * indicative of changes on input signal power in the frequency band for
+     * this measurement.
+     */
+    double agcLevelDb;
+
+    /**
+     * The full inter-signal bias (ISB) in nanoseconds.
+     *
+     * This value is the sum of the estimated receiver-side and the space-segment-side inter-system
+     * bias, inter-frequency bias and inter-code bias, including
+     *
+     * - Receiver inter-constellation bias (with respect to the constellation in
+     *   GnssClock.referenceSignalTypeForIsb)
+     * - Receiver inter-frequency bias (with respect to the carrier frequency in
+     *   GnssClock.referenceSignalTypeForIsb)
+     * - Receiver inter-code bias (with respect to the code type in
+     *   GnssClock.referenceSignalTypeForIsb)
+     * - Master clock bias (e.g., GPS-GAL Time Offset (GGTO), GPS-UTC Time Offset (TauGps), BDS-GLO
+     *   Time Offset (BGTO)) (with respect to the constellation in
+     *   GnssClock.referenceSignalTypeForIsb)
+     * - Group delay (e.g., Total Group Delay (TGD))
+     * - Satellite inter-frequency bias (GLO only) (with respect to the carrier frequency in
+     *   GnssClock.referenceSignalTypeForIsb)
+     * - Satellite inter-code bias (e.g., Differential Code Bias (DCB)) (with respect to the code
+     *   type in GnssClock.referenceSignalTypeForIsb)
+     *
+     * If a component of the above is already compensated in the provided
+     * GnssMeasurement.receivedSvTimeInNs, then it must not be included in the reported full ISB.
+     *
+     * The value does not include the inter-frequency Ionospheric bias.
+     *
+     * The full ISB of GnssClock.referenceSignalTypeForIsb is defined to be 0.0 nanoseconds.
+     */
+    double fullInterSignalBiasNs;
+
+    /**
+     * 1-sigma uncertainty associated with the full inter-signal bias in nanoseconds.
+     */
+    double fullInterSignalBiasUncertaintyNs;
+
+    /**
+     * The satellite inter-signal bias in nanoseconds.
+     *
+     * This value is the sum of the space-segment-side inter-system bias, inter-frequency bias
+     * and inter-code bias, including
+     *
+     * - Master clock bias (e.g., GPS-GAL Time Offset (GGTO), GPS-UTC Time Offset (TauGps), BDS-GLO
+     *   Time Offset (BGTO)) (with respect to the constellation in
+     *   GnssClock.referenceSignalTypeForIsb)
+     * - Group delay (e.g., Total Group Delay (TGD))
+     * - Satellite inter-frequency bias (GLO only) (with respect to the carrier frequency in
+     *   GnssClock.referenceSignalTypeForIsb)
+     * - Satellite inter-code bias (e.g., Differential Code Bias (DCB)) (with respect to the code
+     *   type in GnssClock.referenceSignalTypeForIsb)
+     *
+     * The satellite ISB of GnssClock.referenceSignalTypeForIsb is defined to be 0.0 nanoseconds.
+     */
+    double satelliteInterSignalBiasNs;
+
+    /**
+     * 1-sigma uncertainty associated with the satellite inter-signal bias in nanoseconds.
+     */
+    double satelliteInterSignalBiasUncertaintyNs;
+}
\ No newline at end of file
diff --git a/keymint/aidl/android/hardware/keymint/Algorithm.aidl b/gnss/aidl/android/hardware/gnss/GnssMultipathIndicator.aidl
similarity index 61%
copy from keymint/aidl/android/hardware/keymint/Algorithm.aidl
copy to gnss/aidl/android/hardware/gnss/GnssMultipathIndicator.aidl
index 8c5d99c..ec1ce62 100644
--- a/keymint/aidl/android/hardware/keymint/Algorithm.aidl
+++ b/gnss/aidl/android/hardware/gnss/GnssMultipathIndicator.aidl
@@ -14,24 +14,19 @@
  * limitations under the License.
  */
 
-package android.hardware.keymint;
-
+package android.hardware.gnss;
 
 /**
- * Algorithms provided by IKeyMintDevice implementations.
+ * Enumeration of available values for the GNSS Measurement's multipath
+ * indicator.
  */
 @VintfStability
 @Backing(type="int")
-enum Algorithm {
-    /** Asymmetric algorithms. */
-    RSA = 1,
-    /** 2 removed, do not reuse. */
-    EC = 3,
-
-    /** Block cipher algorithms */
-    AES = 32,
-    TRIPLE_DES = 33,
-
-    /** MAC algorithms */
-    HMAC = 128,
-}
+enum GnssMultipathIndicator {
+    /** The indicator is not available or unknown. */
+    UNKNOWN      = 0,
+    /** The measurement is indicated to be affected by multipath. */
+    PRESENT      = 1,
+    /** The measurement is indicated to be not affected by multipath. */
+    NOT_PRESENT = 2,
+}
\ No newline at end of file
diff --git a/gnss/aidl/android/hardware/gnss/GnssSignalType.aidl b/gnss/aidl/android/hardware/gnss/GnssSignalType.aidl
new file mode 100644
index 0000000..9c68db1
--- /dev/null
+++ b/gnss/aidl/android/hardware/gnss/GnssSignalType.aidl
@@ -0,0 +1,149 @@
+/*
+ * 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.
+ */
+
+package android.hardware.gnss;
+
+import android.hardware.gnss.GnssConstellationType;
+
+/**
+ * Represents a GNSS signal type.
+ */
+@VintfStability
+parcelable GnssSignalType {
+    /**
+     * Constellation type of the SV that transmits the signal.
+     */
+    GnssConstellationType constellation;
+
+    /**
+     * Carrier frequency of the signal tracked, for example it can be the
+     * GPS central frequency for L1 = 1575.45 MHz, or L2 = 1227.60 MHz, L5 =
+     * 1176.45 MHz, varying GLO channels, etc. If the field is not set, it
+     * is the primary common use central frequency, e.g. L1 = 1575.45 MHz
+     * for GPS.
+     *
+     * For an L1, L5 receiver tracking a satellite on L1 and L5 at the same
+     * time, two raw measurement structs must be reported for this same
+     * satellite, in one of the measurement structs, all the values related
+     * to L1 must be filled, and in the other all of the values related to
+     * L5 must be filled.
+     */
+    double carrierFrequencyHz;
+
+    /**
+     * GNSS signal code type "A" representing GALILEO E1A, GALILEO E6A, IRNSS L5A, IRNSS SA.
+     */
+    const @utf8InCpp String CODE_TYPE_A = "A";
+
+    /**
+     * GNSS signal code type "B" representing GALILEO E1B, GALILEO E6B, IRNSS L5B, IRNSS SB.
+     */
+    const @utf8InCpp String CODE_TYPE_B = "B";
+
+    /**
+     * GNSS signal code type "C" representing GPS L1 C/A,  GPS L2 C/A, GLONASS G1 C/A,
+     * GLONASS G2 C/A, GALILEO E1C, GALILEO E6C, SBAS L1 C/A, QZSS L1 C/A, IRNSS L5C.
+     */
+    const @utf8InCpp String CODE_TYPE_C = "C";
+
+    /**
+     * GNSS signal code type "D" representing BDS B1C D.
+     */
+    const @utf8InCpp String CODE_TYPE_D = "D";
+
+    /**
+     * GNSS signal code type "I" representing GPS L5 I, GLONASS G3 I, GALILEO E5a I, GALILEO E5b I,
+     * GALILEO E5a+b I, SBAS L5 I, QZSS L5 I, BDS B1 I, BDS B2 I, BDS B3 I.
+     */
+    const @utf8InCpp String CODE_TYPE_I = "I";
+
+    /**
+     * GNSS signal code type "L" representing GPS L1C (P), GPS L2C (L), QZSS L1C (P), QZSS L2C (L),
+     * LEX(6) L.
+     */
+    const @utf8InCpp String CODE_TYPE_L = "L";
+
+    /**
+     * GNSS signal code type "M" representing GPS L1M, GPS L2M.
+     */
+    const @utf8InCpp String CODE_TYPE_M = "M";
+
+    /**
+     * GNSS signal code type "N" representing GPS L1 codeless, GPS L2 codeless.
+     */
+    const @utf8InCpp String CODE_TYPE_N = "N";
+
+    /**
+     * GNSS signal code type "P" representing GPS L1P, GPS L2P, GLONASS G1P, GLONASS G2P, BDS B1C P.
+     */
+    const @utf8InCpp String CODE_TYPE_P = "P";
+
+    /**
+     * GNSS signal code type "Q" representing GPS L5 Q, GLONASS G3 Q, GALILEO E5a Q, GALILEO E5b Q,
+     * GALILEO E5a+b Q, SBAS L5 Q, QZSS L5 Q, BDS B1 Q, BDS B2 Q, BDS B3 Q.
+     */
+    const @utf8InCpp String CODE_TYPE_Q = "Q";
+
+    /**
+     * GNSS signal code type "S" represents GPS L1C (D), GPS L2C (M), QZSS L1C (D), QZSS L2C (M),
+     * LEX(6) S.
+     */
+    const @utf8InCpp String CODE_TYPE_S = "S";
+
+    /**
+     * GNSS signal code type "W" representing GPS L1 Z-tracking, GPS L2 Z-tracking.
+     */
+    const @utf8InCpp String CODE_TYPE_W = "W";
+
+    /**
+     * GNSS signal code type "X" representing GPS L1C (D+P), GPS L2C (M+L), GPS L5 (I+Q),
+     * GLONASS G3 (I+Q), GALILEO E1 (B+C), GALILEO E5a (I+Q), GALILEO E5b (I+Q), GALILEO E5a+b(I+Q),
+     * GALILEO E6 (B+C), SBAS L5 (I+Q), QZSS L1C (D+P), QZSS L2C (M+L), QZSS L5 (I+Q),
+     * LEX(6) (S+L), BDS B1 (I+Q), BDS B1C (D+P), BDS B2 (I+Q), BDS B3 (I+Q), IRNSS L5 (B+C).
+     */
+    const @utf8InCpp String CODE_TYPE_X = "X";
+
+    /**
+     * GNSS signal code type "Y" representing GPS L1Y, GPS L2Y.
+     */
+    const @utf8InCpp String CODE_TYPE_Y = "Y";
+
+    /**
+     * GNSS signal code type "Z" representing GALILEO E1 (A+B+C), GALILEO E6 (A+B+C), QZSS L1-SAIF.
+     */
+    const @utf8InCpp String CODE_TYPE_Z = "Z";
+
+    /**
+     * GNSS signal code type "UNKNOWN" representing the GNSS Measurement's code type is unknown.
+     */
+    const @utf8InCpp String CODE_TYPE_UNKNOWN = "UNKNOWN";
+
+    /**
+     * The type of code that is currently being tracked in the GNSS signal.
+     *
+     * For high precision applications the type of code being tracked needs to be considered
+     * in-order to properly apply code specific corrections to the pseudorange measurements.
+     *
+     * The value is one of the constant Strings with prefix CODE_TYPE_ defined in this parcelable.
+     *
+     * This is used to specify the observation descriptor defined in GNSS Observation Data File
+     * Header Section Description in the RINEX standard (Version 3.XX). In RINEX Version 3.03,
+     * in Appendix Table A2 Attributes are listed as uppercase letters (for instance, "A" for
+     * "A channel"). In the future, if for instance a code "G" was added in the official RINEX
+     * standard, "G" could be specified here.
+     */
+    @utf8InCpp String codeType;
+}
diff --git a/gnss/aidl/android/hardware/gnss/IGnss.aidl b/gnss/aidl/android/hardware/gnss/IGnss.aidl
index 2af57b5..c815e2d 100644
--- a/gnss/aidl/android/hardware/gnss/IGnss.aidl
+++ b/gnss/aidl/android/hardware/gnss/IGnss.aidl
@@ -17,9 +17,10 @@
 package android.hardware.gnss;
 
 import android.hardware.gnss.IGnssCallback;
+import android.hardware.gnss.IGnssConfiguration;
+import android.hardware.gnss.IGnssMeasurementInterface;
 import android.hardware.gnss.IGnssPowerIndication;
 import android.hardware.gnss.IGnssPsds;
-import android.hardware.gnss.IGnssConfiguration;
 
 /**
  * Represents the standard GNSS (Global Navigation Satellite System) interface.
@@ -33,14 +34,6 @@
      */
     const int ERROR_INVALID_ARGUMENT = 1;
 
-    /** Bit mask indicating a valid timestampNs is stored in the ElapsedRealtime parcelable. */
-    const int ELAPSED_REALTIME_HAS_TIMESTAMP_NS = 1 << 0;
-
-    /**
-     * Bit mask indicating a valid timeUncertaintyNs is stored in the ElapsedRealtime parcelable.
-     */
-    const int ELAPSED_REALTIME_HAS_TIME_UNCERTAINTY_NS = 1 << 1;
-
     /**
      * Opens the interface and provides the callback routines to the implementation of this
      * interface.
@@ -74,6 +67,8 @@
     /**
      * This method returns the IGnssPsds interface.
      *
+     * This method must return non-null.
+     *
      * @return Handle to the IGnssPsds interface.
      */
     IGnssPsds getExtensionPsds();
@@ -81,13 +76,26 @@
     /**
      * This method returns the IGnssConfiguration interface.
      *
+     * This method must return non-null.
+     *
      * @return Handle to the IGnssConfiguration interface.
      */
     IGnssConfiguration getExtensionGnssConfiguration();
 
     /**
+     * This methods returns the IGnssMeasurementInterface interface.
+     *
+     * This method must return non-null.
+     *
+     * @return Handle to the IGnssMeasurementInterface interface.
+     */
+    IGnssMeasurementInterface getExtensionGnssMeasurement();
+
+    /**
      * This method returns the IGnssPowerIndication interface.
      *
+     * This method must return non-null.
+     *
      * @return Handle to the IGnssPowerIndication interface.
      */
     IGnssPowerIndication getExtensionGnssPowerIndication();
diff --git a/keymint/aidl/android/hardware/keymint/SecurityLevel.aidl b/gnss/aidl/android/hardware/gnss/IGnssMeasurementCallback.aidl
similarity index 63%
copy from keymint/aidl/android/hardware/keymint/SecurityLevel.aidl
copy to gnss/aidl/android/hardware/gnss/IGnssMeasurementCallback.aidl
index d8de024..328cf2a 100644
--- a/keymint/aidl/android/hardware/keymint/SecurityLevel.aidl
+++ b/gnss/aidl/android/hardware/gnss/IGnssMeasurementCallback.aidl
@@ -14,19 +14,19 @@
  * limitations under the License.
  */
 
-package android.hardware.keymint;
+package android.hardware.gnss;
+
+import android.hardware.gnss.GnssData;
 
 /**
- * Device security levels.
+ * The callback interface to report GNSS Measurement from the HAL.
  */
 @VintfStability
-@Backing(type="int")
-enum SecurityLevel {
-    SOFTWARE = 0,
-    TRUSTED_ENVIRONMENT = 1,
+interface IGnssMeasurementCallback {
     /**
-     * STRONGBOX specifies that the secure hardware satisfies the requirements specified in CDD
-     * 9.11.2.
+     * Callback for the hal to pass a GnssData structure back to the client.
+     *
+     * @param data Contains a reading of GNSS measurements.
      */
-    STRONGBOX = 2,
-}
+    void gnssMeasurementCb(in GnssData data);
+}
\ No newline at end of file
diff --git a/gnss/aidl/android/hardware/gnss/IGnssMeasurementInterface.aidl b/gnss/aidl/android/hardware/gnss/IGnssMeasurementInterface.aidl
new file mode 100644
index 0000000..fdeebde
--- /dev/null
+++ b/gnss/aidl/android/hardware/gnss/IGnssMeasurementInterface.aidl
@@ -0,0 +1,55 @@
+/*
+ * 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.
+ */
+
+package android.hardware.gnss;
+
+import android.hardware.gnss.IGnssMeasurementCallback;
+
+/**
+ * Extended interface for GNSS Measurement support.
+ */
+@VintfStability
+interface IGnssMeasurementInterface {
+    /**
+     * Initializes the interface and registers the callback routines with the HAL. After a
+     * successful call to 'setCallback' the HAL must begin to provide updates at an average
+     * output rate of 1Hz (occasional intra-measurement time offsets in the range from 0-2000msec
+     * can be tolerated.)
+     *
+     * @param callback Handle to GnssMeasurement callback interface.
+     * @param enableFullTracking If true, GNSS chipset must switch off duty cycling. In such mode
+     *     no clock discontinuities are expected and, when supported, carrier phase should be
+     *     continuous in good signal conditions. All non-blocklisted, healthy constellations,
+     *     satellites and frequency bands that the chipset supports must be reported in this mode.
+     *     The GNSS chipset is allowed to consume more power in this mode. If false, API must
+     *     optimize power via duty cycling, constellations and frequency limits, etc.
+     *
+     * @return initRet Returns SUCCESS if successful. Returns ERROR_ALREADY_INIT if a callback has
+     *     already been registered without a corresponding call to 'close'. Returns ERROR_GENERIC
+     *     for any other error. The HAL must not generate any other updates upon returning this
+     *     error code.
+     */
+    void setCallback(in IGnssMeasurementCallback callback, in boolean enableFullTracking);
+
+    /**
+     * Stops updates from the HAL, and unregisters the callback routines. After a call to close(),
+     * the previously registered callbacks must be considered invalid by the HAL.
+     *
+     * If close() is invoked without a previous setCallback, this function must perform
+     * no work.
+     */
+    void close();
+}
\ No newline at end of file
diff --git a/gnss/aidl/default/Android.bp b/gnss/aidl/default/Android.bp
index 23677ed..6694ce6 100644
--- a/gnss/aidl/default/Android.bp
+++ b/gnss/aidl/default/Android.bp
@@ -50,6 +50,7 @@
         "GnssPowerIndication.cpp",
         "GnssPsds.cpp",
         "GnssConfiguration.cpp",
+        "GnssMeasurementInterface.cpp",
         "service.cpp",
     ],
     static_libs: [
diff --git a/gnss/aidl/default/Gnss.cpp b/gnss/aidl/default/Gnss.cpp
index 669372b..02bad60 100644
--- a/gnss/aidl/default/Gnss.cpp
+++ b/gnss/aidl/default/Gnss.cpp
@@ -19,6 +19,7 @@
 #include "Gnss.h"
 #include <log/log.h>
 #include "GnssConfiguration.h"
+#include "GnssMeasurementInterface.h"
 #include "GnssPowerIndication.h"
 #include "GnssPsds.h"
 
@@ -74,4 +75,12 @@
     return ndk::ScopedAStatus::ok();
 }
 
+ndk::ScopedAStatus Gnss::getExtensionGnssMeasurement(
+        std::shared_ptr<IGnssMeasurementInterface>* iGnssMeasurement) {
+    ALOGD("Gnss::getExtensionGnssMeasurement");
+
+    *iGnssMeasurement = SharedRefBase::make<GnssMeasurementInterface>();
+    return ndk::ScopedAStatus::ok();
+}
+
 }  // namespace aidl::android::hardware::gnss
diff --git a/gnss/aidl/default/Gnss.h b/gnss/aidl/default/Gnss.h
index 9f6ef0e..bccc7f2 100644
--- a/gnss/aidl/default/Gnss.h
+++ b/gnss/aidl/default/Gnss.h
@@ -18,6 +18,7 @@
 
 #include <aidl/android/hardware/gnss/BnGnss.h>
 #include <aidl/android/hardware/gnss/BnGnssConfiguration.h>
+#include <aidl/android/hardware/gnss/BnGnssMeasurementInterface.h>
 #include <aidl/android/hardware/gnss/BnGnssPowerIndication.h>
 #include <aidl/android/hardware/gnss/BnGnssPsds.h>
 #include "GnssConfiguration.h"
@@ -33,6 +34,8 @@
             std::shared_ptr<IGnssConfiguration>* iGnssConfiguration) override;
     ndk::ScopedAStatus getExtensionGnssPowerIndication(
             std::shared_ptr<IGnssPowerIndication>* iGnssPowerIndication) override;
+    ndk::ScopedAStatus getExtensionGnssMeasurement(
+            std::shared_ptr<IGnssMeasurementInterface>* iGnssMeasurement) override;
 
     std::shared_ptr<GnssConfiguration> mGnssConfiguration;
 
diff --git a/gnss/aidl/default/GnssConfiguration.h b/gnss/aidl/default/GnssConfiguration.h
index 25fa16e..491733c 100644
--- a/gnss/aidl/default/GnssConfiguration.h
+++ b/gnss/aidl/default/GnssConfiguration.h
@@ -24,8 +24,6 @@
 
 namespace aidl::android::hardware::gnss {
 
-using android::hardware::gnss::GnssConstellationType;
-
 struct BlocklistedSourceHash {
     inline int operator()(const BlocklistedSource& source) const {
         return int(source.constellation) * 1000 + int(source.svid);
@@ -42,7 +40,8 @@
 using std::vector;
 using BlocklistedSourceSet =
         std::unordered_set<BlocklistedSource, BlocklistedSourceHash, BlocklistedSourceEqual>;
-using BlocklistedConstellationSet = std::unordered_set<GnssConstellationType>;
+using BlocklistedConstellationSet =
+        std::unordered_set<android::hardware::gnss::GnssConstellationType>;
 
 struct GnssConfiguration : public BnGnssConfiguration {
   public:
diff --git a/gnss/aidl/default/GnssHidlHal.cpp b/gnss/aidl/default/GnssHidlHal.cpp
index 11fc806..9529ec9 100644
--- a/gnss/aidl/default/GnssHidlHal.cpp
+++ b/gnss/aidl/default/GnssHidlHal.cpp
@@ -17,11 +17,10 @@
 #define LOG_TAG "GnssHidlHal"
 
 #include "GnssHidlHal.h"
-//#include <android/hardware/gnss/1.0/IGnssCallback.h>
 
 namespace aidl::android::hardware::gnss {
 
-namespace V1_0 = ::android::hardware::gnss::V1_0;
+using GnssSvInfo = ::android::hardware::gnss::V2_1::IGnssCallback::GnssSvInfo;
 
 GnssHidlHal::GnssHidlHal(const std::shared_ptr<Gnss>& gnssAidl) : mGnssAidl(gnssAidl) {
     Gnss* iGnss = mGnssAidl.get();
@@ -45,8 +44,8 @@
         if (mGnssConfigurationAidl->isBlocklistedV2_1(gnssSvInfoList[i])) {
             ALOGD("Blocklisted constellation: %d, svid: %d",
                   (int)gnssSvInfoList[i].v2_0.constellation, gnssSvInfoList[i].v2_0.v1_0.svid);
-            gnssSvInfoList[i].v2_0.v1_0.svFlag &=
-                    ~static_cast<uint8_t>(V1_0::IGnssCallback::GnssSvFlags::USED_IN_FIX);
+            gnssSvInfoList[i].v2_0.v1_0.svFlag &= ~static_cast<uint8_t>(
+                    ::android::hardware::gnss::V1_0::IGnssCallback::GnssSvFlags::USED_IN_FIX);
         }
     }
     return gnssSvInfoList;
diff --git a/gnss/aidl/default/GnssHidlHal.h b/gnss/aidl/default/GnssHidlHal.h
index 50aad3a..93a79a1 100644
--- a/gnss/aidl/default/GnssHidlHal.h
+++ b/gnss/aidl/default/GnssHidlHal.h
@@ -22,16 +22,16 @@
 
 namespace aidl::android::hardware::gnss {
 
-using ::android::hardware::gnss::common::implementation::GnssTemplate;
-using GnssSvInfo = ::android::hardware::gnss::V2_1::IGnssCallback::GnssSvInfo;
-
-class GnssHidlHal : public GnssTemplate<::android::hardware::gnss::V2_1::IGnss> {
+class GnssHidlHal : public ::android::hardware::gnss::common::implementation::GnssTemplate<
+                            ::android::hardware::gnss::V2_1::IGnss> {
   public:
     GnssHidlHal(const std::shared_ptr<Gnss>& gnssAidl);
 
   private:
-    hidl_vec<GnssSvInfo> filterBlocklistedSatellitesV2_1(
-            hidl_vec<GnssSvInfo> gnssSvInfoList) override;
+    hidl_vec<::android::hardware::gnss::V2_1::IGnssCallback::GnssSvInfo>
+    filterBlocklistedSatellitesV2_1(
+            hidl_vec<::android::hardware::gnss::V2_1::IGnssCallback::GnssSvInfo> gnssSvInfoList)
+            override;
 
     std::shared_ptr<Gnss> mGnssAidl;
     std::shared_ptr<GnssConfiguration> mGnssConfigurationAidl;
diff --git a/gnss/aidl/default/GnssMeasurementInterface.cpp b/gnss/aidl/default/GnssMeasurementInterface.cpp
new file mode 100644
index 0000000..d726d95
--- /dev/null
+++ b/gnss/aidl/default/GnssMeasurementInterface.cpp
@@ -0,0 +1,90 @@
+/*
+ * 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.
+ */
+
+#define LOG_TAG "GnssMeasIfaceAidl"
+
+#include "GnssMeasurementInterface.h"
+#include <aidl/android/hardware/gnss/BnGnss.h>
+#include <log/log.h>
+#include "Utils.h"
+
+namespace aidl::android::hardware::gnss {
+
+using Utils = ::android::hardware::gnss::common::Utils;
+
+std::shared_ptr<IGnssMeasurementCallback> GnssMeasurementInterface::sCallback = nullptr;
+
+GnssMeasurementInterface::GnssMeasurementInterface() : mMinIntervalMillis(1000) {}
+
+GnssMeasurementInterface::~GnssMeasurementInterface() {
+    stop();
+}
+
+ndk::ScopedAStatus GnssMeasurementInterface::setCallback(
+        const std::shared_ptr<IGnssMeasurementCallback>& callback, const bool enableFullTracking) {
+    ALOGD("setCallback: enableFullTracking: %d", (int)enableFullTracking);
+    std::unique_lock<std::mutex> lock(mMutex);
+    sCallback = callback;
+
+    if (mIsActive) {
+        ALOGW("GnssMeasurement callback already set. Resetting the callback...");
+        stop();
+    }
+    start();
+
+    return ndk::ScopedAStatus::ok();
+}
+
+ndk::ScopedAStatus GnssMeasurementInterface::close() {
+    ALOGD("close");
+    stop();
+    std::unique_lock<std::mutex> lock(mMutex);
+    sCallback = nullptr;
+    return ndk::ScopedAStatus::ok();
+}
+
+void GnssMeasurementInterface::start() {
+    ALOGD("start");
+    mIsActive = true;
+    mThread = std::thread([this]() {
+        while (mIsActive == true) {
+            auto measurement = Utils::getMockMeasurement();
+            this->reportMeasurement(measurement);
+
+            std::this_thread::sleep_for(std::chrono::milliseconds(mMinIntervalMillis));
+        }
+    });
+}
+
+void GnssMeasurementInterface::stop() {
+    ALOGD("stop");
+    mIsActive = false;
+    if (mThread.joinable()) {
+        mThread.join();
+    }
+}
+
+void GnssMeasurementInterface::reportMeasurement(const GnssData& data) {
+    ALOGD("reportMeasurement()");
+    std::unique_lock<std::mutex> lock(mMutex);
+    if (sCallback == nullptr) {
+        ALOGE("%s: GnssMeasurement::sCallback is null.", __func__);
+        return;
+    }
+    sCallback->gnssMeasurementCb(data);
+}
+
+}  // namespace aidl::android::hardware::gnss
diff --git a/gnss/aidl/default/GnssMeasurementInterface.h b/gnss/aidl/default/GnssMeasurementInterface.h
new file mode 100644
index 0000000..69cd871
--- /dev/null
+++ b/gnss/aidl/default/GnssMeasurementInterface.h
@@ -0,0 +1,51 @@
+/*
+ * 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.
+ */
+
+#pragma once
+
+#include <aidl/android/hardware/gnss/BnGnssMeasurementCallback.h>
+#include <aidl/android/hardware/gnss/BnGnssMeasurementInterface.h>
+#include <atomic>
+#include <mutex>
+#include <thread>
+
+namespace aidl::android::hardware::gnss {
+
+struct GnssMeasurementInterface : public BnGnssMeasurementInterface {
+  public:
+    GnssMeasurementInterface();
+    ~GnssMeasurementInterface();
+    ndk::ScopedAStatus setCallback(const std::shared_ptr<IGnssMeasurementCallback>& callback,
+                                   const bool enableFullTracking) override;
+    ndk::ScopedAStatus close() override;
+
+  private:
+    void start();
+    void stop();
+    void reportMeasurement(const GnssData&);
+
+    std::atomic<long> mMinIntervalMillis;
+    std::atomic<bool> mIsActive;
+    std::thread mThread;
+
+    // Guarded by mMutex
+    static std::shared_ptr<IGnssMeasurementCallback> sCallback;
+
+    // Synchronization lock for sCallback
+    mutable std::mutex mMutex;
+};
+
+}  // namespace aidl::android::hardware::gnss
diff --git a/gnss/aidl/default/GnssPowerIndication.cpp b/gnss/aidl/default/GnssPowerIndication.cpp
index 8ea60f3..429cc8c 100644
--- a/gnss/aidl/default/GnssPowerIndication.cpp
+++ b/gnss/aidl/default/GnssPowerIndication.cpp
@@ -19,6 +19,7 @@
 #include "GnssPowerIndication.h"
 #include <aidl/android/hardware/gnss/BnGnss.h>
 #include <log/log.h>
+#include <utils/SystemClock.h>
 
 namespace aidl::android::hardware::gnss {
 
@@ -43,10 +44,9 @@
     std::unique_lock<std::mutex> lock(mMutex);
 
     ElapsedRealtime elapsedRealtime = {
-            .flags = IGnss::ELAPSED_REALTIME_HAS_TIMESTAMP_NS |
-                     IGnss::ELAPSED_REALTIME_HAS_TIME_UNCERTAINTY_NS,
-            .timestampNs = (long)1323542,
-            .timeUncertaintyNs = (long)1000,
+            .flags = ElapsedRealtime::HAS_TIMESTAMP_NS | ElapsedRealtime::HAS_TIME_UNCERTAINTY_NS,
+            .timestampNs = ::android::elapsedRealtimeNano(),
+            .timeUncertaintyNs = 1000,
     };
     GnssPowerStats gnssPowerStats = {
             .elapsedRealtime = elapsedRealtime,
diff --git a/gnss/aidl/vts/Android.bp b/gnss/aidl/vts/Android.bp
index d102e7f..c10e809 100644
--- a/gnss/aidl/vts/Android.bp
+++ b/gnss/aidl/vts/Android.bp
@@ -22,6 +22,7 @@
         "gnss_hal_test.cpp",
         "gnss_hal_test_cases.cpp",
         "GnssCallbackAidl.cpp",
+        "GnssMeasurementCallbackAidl.cpp",
         "GnssPowerIndicationCallback.cpp",
         "VtsHalGnssTargetTest.cpp",
     ],
diff --git a/gnss/aidl/vts/GnssMeasurementCallbackAidl.cpp b/gnss/aidl/vts/GnssMeasurementCallbackAidl.cpp
new file mode 100644
index 0000000..c4fad7f
--- /dev/null
+++ b/gnss/aidl/vts/GnssMeasurementCallbackAidl.cpp
@@ -0,0 +1,35 @@
+/*
+ * 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.
+ */
+
+#define LOG_TAG "GnssMeasurementCallbackAidl"
+
+#include "GnssMeasurementCallbackAidl.h"
+#include <inttypes.h>
+#include <log/log.h>
+
+using android::hardware::gnss::GnssData;
+
+android::binder::Status GnssMeasurementCallbackAidl::gnssMeasurementCb(const GnssData& gnssData) {
+    ALOGI("gnssMeasurementCb");
+    ALOGI("elapsedRealtime: flags = %d, timestampNs: %" PRId64 ", timeUncertaintyNs=%lf",
+          gnssData.elapsedRealtime.flags, gnssData.elapsedRealtime.timestampNs,
+          gnssData.elapsedRealtime.timeUncertaintyNs);
+    for (const auto& measurement : gnssData.measurements) {
+        ALOGI("measurement.receivedSvTimeInNs=%" PRId64, measurement.receivedSvTimeInNs);
+    }
+    gnss_data_cbq_.store(gnssData);
+    return android::binder::Status::ok();
+}
diff --git a/gnss/aidl/vts/GnssMeasurementCallbackAidl.h b/gnss/aidl/vts/GnssMeasurementCallbackAidl.h
new file mode 100644
index 0000000..f6c79cf
--- /dev/null
+++ b/gnss/aidl/vts/GnssMeasurementCallbackAidl.h
@@ -0,0 +1,33 @@
+/*
+ * 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.
+ */
+
+#pragma once
+
+#include <android/hardware/gnss/BnGnssMeasurementCallback.h>
+#include "GnssCallbackEventQueue.h"
+
+/** Implementation for IGnssMeasurementCallback. */
+class GnssMeasurementCallbackAidl : public android::hardware::gnss::BnGnssMeasurementCallback {
+  public:
+    GnssMeasurementCallbackAidl() : gnss_data_cbq_("gnss_data") {}
+    ~GnssMeasurementCallbackAidl() {}
+
+    android::binder::Status gnssMeasurementCb(
+            const android::hardware::gnss::GnssData& gnssData) override;
+
+    android::hardware::gnss::common::GnssCallbackEventQueue<android::hardware::gnss::GnssData>
+            gnss_data_cbq_;
+};
diff --git a/gnss/aidl/vts/GnssPowerIndicationCallback.h b/gnss/aidl/vts/GnssPowerIndicationCallback.h
index d4c4539..3416f17 100644
--- a/gnss/aidl/vts/GnssPowerIndicationCallback.h
+++ b/gnss/aidl/vts/GnssPowerIndicationCallback.h
@@ -25,7 +25,6 @@
   public:
     GnssPowerIndicationCallback()
         : capabilities_cbq_("capabilities"),
-          other_mode_names_cbq_("other_mode_names"),
           gnss_power_stats_cbq_("gnss_power_stats") {}
     ~GnssPowerIndicationCallback() {}
 
@@ -35,9 +34,6 @@
 
     android::hardware::gnss::common::GnssCallbackEventQueue<int> capabilities_cbq_;
     int last_capabilities_;
-    android::hardware::gnss::common::GnssCallbackEventQueue<std::vector<std::string>>
-            other_mode_names_cbq_;
-    std::vector<std::string> last_other_mode_names_;
     android::hardware::gnss::common::GnssCallbackEventQueue<android::hardware::gnss::GnssPowerStats>
             gnss_power_stats_cbq_;
     android::hardware::gnss::GnssPowerStats last_gnss_power_stats_;
diff --git a/gnss/aidl/vts/gnss_hal_test.h b/gnss/aidl/vts/gnss_hal_test.h
index eb5301e..f72f7fe 100644
--- a/gnss/aidl/vts/gnss_hal_test.h
+++ b/gnss/aidl/vts/gnss_hal_test.h
@@ -36,7 +36,7 @@
 using android::hardware::gnss::IGnssConfiguration;
 
 // The main test class for GNSS HAL.
-class GnssHalTest : public GnssHalTestTemplate<IGnss_V2_1> {
+class GnssHalTest : public android::hardware::gnss::common::GnssHalTestTemplate<IGnss_V2_1> {
   public:
     GnssHalTest(){};
     ~GnssHalTest(){};
diff --git a/gnss/aidl/vts/gnss_hal_test_cases.cpp b/gnss/aidl/vts/gnss_hal_test_cases.cpp
index 4e8d0bd..857c742 100644
--- a/gnss/aidl/vts/gnss_hal_test_cases.cpp
+++ b/gnss/aidl/vts/gnss_hal_test_cases.cpp
@@ -16,19 +16,30 @@
 
 #define LOG_TAG "GnssHalTestCases"
 
+#include <android/hardware/gnss/IGnss.h>
+#include <android/hardware/gnss/IGnssMeasurementCallback.h>
+#include <android/hardware/gnss/IGnssMeasurementInterface.h>
 #include <android/hardware/gnss/IGnssPowerIndication.h>
 #include <android/hardware/gnss/IGnssPsds.h>
+#include "GnssMeasurementCallbackAidl.h"
 #include "GnssPowerIndicationCallback.h"
 #include "gnss_hal_test.h"
 
 using android::sp;
 using android::hardware::gnss::BlocklistedSource;
-using GnssConstellationTypeAidl = android::hardware::gnss::GnssConstellationType;
+using android::hardware::gnss::ElapsedRealtime;
+using android::hardware::gnss::GnssClock;
+using android::hardware::gnss::GnssMeasurement;
+using android::hardware::gnss::IGnss;
 using android::hardware::gnss::IGnssConfiguration;
+using android::hardware::gnss::IGnssMeasurementCallback;
+using android::hardware::gnss::IGnssMeasurementInterface;
 using android::hardware::gnss::IGnssPowerIndication;
 using android::hardware::gnss::IGnssPsds;
 using android::hardware::gnss::PsdsType;
 
+using GnssConstellationTypeAidl = android::hardware::gnss::GnssConstellationType;
+
 /*
  * SetupTeardownCreateCleanup:
  * Requests the gnss HAL then calls cleanup
@@ -53,6 +64,62 @@
 }
 
 /*
+ * TestGnssMeasurementExtension:
+ * 1. Gets the GnssMeasurementExtension and verifies that it returns a non-null extension.
+ * 2. Sets a GnssMeasurementCallback, waits for a measurement, and verifies fields are valid.
+ */
+TEST_P(GnssHalTest, TestGnssMeasurementExtension) {
+    const int kFirstGnssMeasurementTimeoutSeconds = 10;
+    sp<IGnssMeasurementInterface> iGnssMeasurement;
+    auto status = aidl_gnss_hal_->getExtensionGnssMeasurement(&iGnssMeasurement);
+    ASSERT_TRUE(status.isOk());
+    ASSERT_TRUE(iGnssMeasurement != nullptr);
+
+    auto callback = sp<GnssMeasurementCallbackAidl>::make();
+    status = iGnssMeasurement->setCallback(callback, /* enableFullTracking= */ true);
+    ASSERT_TRUE(status.isOk());
+
+    android::hardware::gnss::GnssData lastMeasurement;
+    ASSERT_TRUE(callback->gnss_data_cbq_.retrieve(lastMeasurement,
+                                                  kFirstGnssMeasurementTimeoutSeconds));
+    EXPECT_EQ(callback->gnss_data_cbq_.calledCount(), 1);
+    ASSERT_TRUE(lastMeasurement.measurements.size() > 0);
+
+    // Validity check GnssData fields
+    ASSERT_TRUE(
+            lastMeasurement.elapsedRealtime.flags >= 0 &&
+            lastMeasurement.elapsedRealtime.flags <=
+                    (ElapsedRealtime::HAS_TIMESTAMP_NS | ElapsedRealtime::HAS_TIME_UNCERTAINTY_NS));
+    if (lastMeasurement.elapsedRealtime.flags & ElapsedRealtime::HAS_TIMESTAMP_NS) {
+        ASSERT_TRUE(lastMeasurement.elapsedRealtime.timestampNs > 0);
+    }
+    if (lastMeasurement.elapsedRealtime.flags & ElapsedRealtime::HAS_TIME_UNCERTAINTY_NS) {
+        ASSERT_TRUE(lastMeasurement.elapsedRealtime.timeUncertaintyNs > 0);
+    }
+    ASSERT_TRUE(lastMeasurement.clock.gnssClockFlags >= 0 &&
+                lastMeasurement.clock.gnssClockFlags <=
+                        (GnssClock::HAS_LEAP_SECOND | GnssClock::HAS_TIME_UNCERTAINTY |
+                         GnssClock::HAS_FULL_BIAS | GnssClock::HAS_BIAS |
+                         GnssClock::HAS_BIAS_UNCERTAINTY | GnssClock::HAS_DRIFT |
+                         GnssClock::HAS_DRIFT_UNCERTAINTY));
+    for (const auto& measurement : lastMeasurement.measurements) {
+        ASSERT_TRUE(
+                measurement.flags >= 0 &&
+                measurement.flags <=
+                        (GnssMeasurement::HAS_SNR | GnssMeasurement::HAS_CARRIER_FREQUENCY |
+                         GnssMeasurement::HAS_CARRIER_CYCLES | GnssMeasurement::HAS_CARRIER_PHASE |
+                         GnssMeasurement::HAS_CARRIER_PHASE_UNCERTAINTY |
+                         GnssMeasurement::HAS_AUTOMATIC_GAIN_CONTROL |
+                         GnssMeasurement::HAS_FULL_ISB | GnssMeasurement::HAS_FULL_ISB_UNCERTAINTY |
+                         GnssMeasurement::HAS_SATELLITE_ISB |
+                         GnssMeasurement::HAS_SATELLITE_ISB_UNCERTAINTY));
+    }
+
+    status = iGnssMeasurement->close();
+    ASSERT_TRUE(status.isOk());
+}
+
+/*
  * TestGnssPowerIndication
  * 1. Gets the GnssPowerIndicationExtension.
  * 2. Sets a GnssPowerIndicationCallback.
diff --git a/gnss/common/utils/default/Android.bp b/gnss/common/utils/default/Android.bp
index 730de4b..be1d532 100644
--- a/gnss/common/utils/default/Android.bp
+++ b/gnss/common/utils/default/Android.bp
@@ -42,5 +42,6 @@
         "android.hardware.gnss@2.1",
         "android.hardware.gnss.measurement_corrections@1.1",
         "android.hardware.gnss.measurement_corrections@1.0",
+        "android.hardware.gnss-ndk_platform",
     ],
 }
diff --git a/gnss/common/utils/default/Utils.cpp b/gnss/common/utils/default/Utils.cpp
index d336f1b..e383d51 100644
--- a/gnss/common/utils/default/Utils.cpp
+++ b/gnss/common/utils/default/Utils.cpp
@@ -17,6 +17,7 @@
 #include <Constants.h>
 #include <MockLocation.h>
 #include <Utils.h>
+#include <aidl/android/hardware/gnss/BnGnss.h>
 #include <utils/SystemClock.h>
 
 namespace android {
@@ -24,16 +25,31 @@
 namespace gnss {
 namespace common {
 
+using aidl::android::hardware::gnss::ElapsedRealtime;
+using aidl::android::hardware::gnss::GnssClock;
+using aidl::android::hardware::gnss::GnssData;
+using aidl::android::hardware::gnss::GnssMeasurement;
+using aidl::android::hardware::gnss::IGnss;
+using aidl::android::hardware::gnss::IGnssMeasurementCallback;
+
 using GnssSvFlags = V1_0::IGnssCallback::GnssSvFlags;
 using GnssMeasurementFlagsV1_0 = V1_0::IGnssMeasurementCallback::GnssMeasurementFlags;
 using GnssMeasurementFlagsV2_1 = V2_1::IGnssMeasurementCallback::GnssMeasurementFlags;
 using GnssMeasurementStateV2_0 = V2_0::IGnssMeasurementCallback::GnssMeasurementState;
-using ElapsedRealtime = V2_0::ElapsedRealtime;
 using ElapsedRealtimeFlags = V2_0::ElapsedRealtimeFlags;
 using GnssConstellationTypeV2_0 = V2_0::GnssConstellationType;
 using IGnssMeasurementCallbackV2_0 = V2_0::IGnssMeasurementCallback;
 using GnssSignalType = V2_1::GnssSignalType;
 
+using GnssDataV2_0 = V2_0::IGnssMeasurementCallback::GnssData;
+using GnssDataV2_1 = V2_1::IGnssMeasurementCallback::GnssData;
+using GnssSvInfoV1_0 = V1_0::IGnssCallback::GnssSvInfo;
+using GnssSvInfoV2_0 = V2_0::IGnssCallback::GnssSvInfo;
+using GnssSvInfoV2_1 = V2_1::IGnssCallback::GnssSvInfo;
+using GnssAntennaInfo = ::android::hardware::gnss::V2_1::IGnssAntennaInfoCallback::GnssAntennaInfo;
+using Row = V2_1::IGnssAntennaInfoCallback::Row;
+using Coord = V2_1::IGnssAntennaInfoCallback::Coord;
+
 GnssDataV2_1 Utils::getMockMeasurementV2_1() {
     GnssDataV2_0 gnssDataV2_0 = Utils::getMockMeasurementV2_0();
     V2_1::IGnssMeasurementCallback::GnssMeasurement gnssMeasurementV2_1 = {
@@ -110,7 +126,7 @@
                                                        .driftUncertaintyNsps = 310.64968328491528,
                                                        .hwClockDiscontinuityCount = 1};
 
-    ElapsedRealtime timestamp = {
+    V2_0::ElapsedRealtime timestamp = {
             .flags = ElapsedRealtimeFlags::HAS_TIMESTAMP_NS |
                      ElapsedRealtimeFlags::HAS_TIME_UNCERTAINTY_NS,
             .timestampNs = static_cast<uint64_t>(::android::elapsedRealtimeNano()),
@@ -124,6 +140,67 @@
     return gnssData;
 }
 
+GnssData Utils::getMockMeasurement() {
+    aidl::android::hardware::gnss::GnssSignalType signalType = {
+            .constellation = aidl::android::hardware::gnss::GnssConstellationType::GLONASS,
+            .carrierFrequencyHz = 1.59975e+09,
+            .codeType = aidl::android::hardware::gnss::GnssSignalType::CODE_TYPE_C,
+    };
+    GnssMeasurement measurement = {
+            .flags = GnssMeasurement::HAS_AUTOMATIC_GAIN_CONTROL |
+                     GnssMeasurement::HAS_CARRIER_FREQUENCY | GnssMeasurement::HAS_CARRIER_PHASE |
+                     GnssMeasurement::HAS_CARRIER_PHASE_UNCERTAINTY |
+                     GnssMeasurement::HAS_FULL_ISB | GnssMeasurement::HAS_FULL_ISB_UNCERTAINTY |
+                     GnssMeasurement::HAS_SATELLITE_ISB |
+                     GnssMeasurement::HAS_SATELLITE_ISB_UNCERTAINTY,
+            .svid = 13,
+            .signalType = signalType,
+            .timeOffsetNs = 0.0,
+            .receivedSvTimeInNs = 8195997131077,
+            .receivedSvTimeUncertaintyInNs = 15,
+            .antennaCN0DbHz = 30.0,
+            .basebandCN0DbHz = 26.5,
+            .agcLevelDb = 2.3,
+            .pseudorangeRateMps = -484.13739013671875,
+            .pseudorangeRateUncertaintyMps = 1.0379999876022339,
+            .accumulatedDeltaRangeState = GnssMeasurement::ADR_STATE_UNKNOWN,
+            .accumulatedDeltaRangeM = 1.52,
+            .accumulatedDeltaRangeUncertaintyM = 2.43,
+            .multipathIndicator = aidl::android::hardware::gnss::GnssMultipathIndicator::UNKNOWN,
+            .state = GnssMeasurement::STATE_CODE_LOCK | GnssMeasurement::STATE_BIT_SYNC |
+                     GnssMeasurement::STATE_SUBFRAME_SYNC | GnssMeasurement::STATE_TOW_DECODED |
+                     GnssMeasurement::STATE_GLO_STRING_SYNC |
+                     GnssMeasurement::STATE_GLO_TOD_DECODED,
+            .fullInterSignalBiasNs = 21.5,
+            .fullInterSignalBiasUncertaintyNs = 792.0,
+            .satelliteInterSignalBiasNs = 233.9,
+            .satelliteInterSignalBiasUncertaintyNs = 921.2,
+    };
+
+    GnssClock clock = {.gnssClockFlags = GnssClock::HAS_FULL_BIAS | GnssClock::HAS_FULL_BIAS |
+                                         GnssClock::HAS_BIAS_UNCERTAINTY | GnssClock::HAS_DRIFT |
+                                         GnssClock::HAS_DRIFT_UNCERTAINTY,
+                       .timeNs = 35854545000000,
+                       .fullBiasNs = -234621900521857520,
+                       .biasNs = 0.2352389998626708984,
+                       .biasUncertaintyNs = 274.989972114563,
+                       .driftNsps = -124.3742360,
+                       .driftUncertaintyNsps = 239.6234285828,
+                       .hwClockDiscontinuityCount = 999};
+
+    ElapsedRealtime timestamp = {
+            .flags = ElapsedRealtime::HAS_TIMESTAMP_NS | ElapsedRealtime::HAS_TIME_UNCERTAINTY_NS,
+            .timestampNs = ::android::elapsedRealtimeNano(),
+            // This is an hardcoded value indicating a 1ms of uncertainty between the two clocks.
+            // In an actual implementation provide an estimate of the synchronization uncertainty
+            // or don't set the field.
+            .timeUncertaintyNs = 1020400};
+
+    GnssData gnssData = {
+            .measurements = {measurement}, .clock = clock, .elapsedRealtime = timestamp};
+    return gnssData;
+}
+
 V2_0::GnssLocation Utils::getMockLocationV2_0() {
     const V2_0::ElapsedRealtime timestamp = {
             .flags = V2_0::ElapsedRealtimeFlags::HAS_TIMESTAMP_NS |
diff --git a/gnss/common/utils/default/include/NmeaFixInfo.h b/gnss/common/utils/default/include/NmeaFixInfo.h
index fb2c1a4..06eae7e 100644
--- a/gnss/common/utils/default/include/NmeaFixInfo.h
+++ b/gnss/common/utils/default/include/NmeaFixInfo.h
@@ -26,11 +26,6 @@
 namespace hardware {
 namespace gnss {
 namespace common {
-using ::android::sp;
-using ::android::hardware::hidl_string;
-using ::android::hardware::hidl_vec;
-using ::android::hardware::Return;
-using ::android::hardware::Void;
 
 constexpr char GPGA_RECORD_TAG[] = "$GPGGA";
 constexpr char GPRMC_RECORD_TAG[] = "$GPRMC";
diff --git a/gnss/common/utils/default/include/Utils.h b/gnss/common/utils/default/include/Utils.h
index d9ad5a5..0ca1b00 100644
--- a/gnss/common/utils/default/include/Utils.h
+++ b/gnss/common/utils/default/include/Utils.h
@@ -17,6 +17,7 @@
 #ifndef android_hardware_gnss_common_default_Utils_H_
 #define android_hardware_gnss_common_default_Utils_H_
 
+#include <aidl/android/hardware/gnss/BnGnssMeasurementInterface.h>
 #include <android/hardware/gnss/1.0/IGnss.h>
 #include <android/hardware/gnss/2.0/IGnss.h>
 #include <android/hardware/gnss/2.1/IGnss.h>
@@ -28,28 +29,22 @@
 namespace gnss {
 namespace common {
 
-using GnssDataV2_0 = V2_0::IGnssMeasurementCallback::GnssData;
-using GnssDataV2_1 = V2_1::IGnssMeasurementCallback::GnssData;
-using GnssSvInfoV1_0 = V1_0::IGnssCallback::GnssSvInfo;
-using GnssSvInfoV2_0 = V2_0::IGnssCallback::GnssSvInfo;
-using GnssSvInfoV2_1 = V2_1::IGnssCallback::GnssSvInfo;
-using GnssAntennaInfo = ::android::hardware::gnss::V2_1::IGnssAntennaInfoCallback::GnssAntennaInfo;
-using Row = ::android::hardware::gnss::V2_1::IGnssAntennaInfoCallback::Row;
-using Coord = ::android::hardware::gnss::V2_1::IGnssAntennaInfoCallback::Coord;
-
 struct Utils {
-    static GnssDataV2_0 getMockMeasurementV2_0();
-    static GnssDataV2_1 getMockMeasurementV2_1();
+    static aidl::android::hardware::gnss::GnssData getMockMeasurement();
+    static V2_0::IGnssMeasurementCallback::GnssData getMockMeasurementV2_0();
+    static V2_1::IGnssMeasurementCallback::GnssData getMockMeasurementV2_1();
     static V2_0::GnssLocation getMockLocationV2_0();
     static V1_0::GnssLocation getMockLocationV1_0();
-    static hidl_vec<GnssSvInfoV2_1> getMockSvInfoListV2_1();
-    static GnssSvInfoV2_1 getMockSvInfoV2_1(GnssSvInfoV2_0 gnssSvInfoV2_0, float basebandCN0DbHz);
-    static GnssSvInfoV2_0 getMockSvInfoV2_0(GnssSvInfoV1_0 gnssSvInfoV1_0,
-                                            V2_0::GnssConstellationType type);
-    static GnssSvInfoV1_0 getMockSvInfoV1_0(int16_t svid, V1_0::GnssConstellationType type,
-                                            float cN0DbHz, float elevationDegrees,
-                                            float azimuthDegrees);
-    static hidl_vec<GnssAntennaInfo> getMockAntennaInfos();
+    static hidl_vec<V2_1::IGnssCallback::GnssSvInfo> getMockSvInfoListV2_1();
+    static V2_1::IGnssCallback::GnssSvInfo getMockSvInfoV2_1(
+            V2_0::IGnssCallback::GnssSvInfo gnssSvInfoV2_0, float basebandCN0DbHz);
+    static V2_0::IGnssCallback::GnssSvInfo getMockSvInfoV2_0(
+            V1_0::IGnssCallback::GnssSvInfo gnssSvInfoV1_0, V2_0::GnssConstellationType type);
+    static V1_0::IGnssCallback::GnssSvInfo getMockSvInfoV1_0(int16_t svid,
+                                                             V1_0::GnssConstellationType type,
+                                                             float cN0DbHz, float elevationDegrees,
+                                                             float azimuthDegrees);
+    static hidl_vec<V2_1::IGnssAntennaInfoCallback::GnssAntennaInfo> getMockAntennaInfos();
 };
 
 }  // namespace common
diff --git a/gnss/common/utils/default/include/v2_1/GnssAntennaInfo.h b/gnss/common/utils/default/include/v2_1/GnssAntennaInfo.h
index e74ff54..a232499 100644
--- a/gnss/common/utils/default/include/v2_1/GnssAntennaInfo.h
+++ b/gnss/common/utils/default/include/v2_1/GnssAntennaInfo.h
@@ -23,29 +23,25 @@
 
 namespace android::hardware::gnss::V2_1::implementation {
 
-using ::android::sp;
-using ::android::hardware::Return;
-using ::android::hardware::Void;
-using IGnssAntennaInfo = ::android::hardware::gnss::V2_1::IGnssAntennaInfo;
-using IGnssAntennaInfoCallback = ::android::hardware::gnss::V2_1::IGnssAntennaInfoCallback;
-
-struct GnssAntennaInfo : public IGnssAntennaInfo {
+struct GnssAntennaInfo : public ::android::hardware::gnss::V2_1::IGnssAntennaInfo {
     GnssAntennaInfo();
     ~GnssAntennaInfo();
 
     // Methods from ::android::hardware::gnss::V2_1::IGnssAntennaInfo follow.
     Return<GnssAntennaInfoStatus> setCallback(
-            const sp<IGnssAntennaInfoCallback>& callback) override;
+            const sp<::android::hardware::gnss::V2_1::IGnssAntennaInfoCallback>& callback) override;
     Return<void> close() override;
 
   private:
     void start();
     void stop();
     void reportAntennaInfo(
-            const hidl_vec<IGnssAntennaInfoCallback::GnssAntennaInfo>& antennaInfo) const;
+            const hidl_vec<
+                    ::android::hardware::gnss::V2_1::IGnssAntennaInfoCallback::GnssAntennaInfo>&
+                    antennaInfo) const;
 
     // Guarded by mMutex
-    static sp<IGnssAntennaInfoCallback> sCallback;
+    static sp<::android::hardware::gnss::V2_1::IGnssAntennaInfoCallback> sCallback;
 
     std::atomic<long> mMinIntervalMillis;
     std::atomic<bool> mIsActive;
diff --git a/gnss/common/utils/default/include/v2_1/GnssConfiguration.h b/gnss/common/utils/default/include/v2_1/GnssConfiguration.h
index 8463a5c..2cfb38f 100644
--- a/gnss/common/utils/default/include/v2_1/GnssConfiguration.h
+++ b/gnss/common/utils/default/include/v2_1/GnssConfiguration.h
@@ -25,35 +25,27 @@
 
 namespace android::hardware::gnss::V2_1::implementation {
 
-using ::android::sp;
-using ::android::hardware::hidl_array;
-using ::android::hardware::hidl_memory;
-using ::android::hardware::hidl_string;
-using ::android::hardware::hidl_vec;
-using ::android::hardware::Return;
-using ::android::hardware::Void;
-
-using BlacklistedSourceV2_1 =
-        ::android::hardware::gnss::V2_1::IGnssConfiguration::BlacklistedSource;
-using GnssConstellationTypeV2_0 = V2_0::GnssConstellationType;
-using GnssSvInfoV2_1 = V2_1::IGnssCallback::GnssSvInfo;
-
 struct BlacklistedSourceHashV2_1 {
-    inline int operator()(const BlacklistedSourceV2_1& source) const {
+    inline int operator()(
+            const ::android::hardware::gnss::V2_1::IGnssConfiguration::BlacklistedSource& source)
+            const {
         return int(source.constellation) * 1000 + int(source.svid);
     }
 };
 
 struct BlacklistedSourceEqualV2_1 {
-    inline bool operator()(const BlacklistedSourceV2_1& s1, const BlacklistedSourceV2_1& s2) const {
+    inline bool operator()(
+            const ::android::hardware::gnss::V2_1::IGnssConfiguration::BlacklistedSource& s1,
+            const ::android::hardware::gnss::V2_1::IGnssConfiguration::BlacklistedSource& s2)
+            const {
         return (s1.constellation == s2.constellation) && (s1.svid == s2.svid);
     }
 };
 
 using BlacklistedSourceSetV2_1 =
-        std::unordered_set<BlacklistedSourceV2_1, BlacklistedSourceHashV2_1,
-                           BlacklistedSourceEqualV2_1>;
-using BlacklistedConstellationSetV2_1 = std::unordered_set<GnssConstellationTypeV2_0>;
+        std::unordered_set<::android::hardware::gnss::V2_1::IGnssConfiguration::BlacklistedSource,
+                           BlacklistedSourceHashV2_1, BlacklistedSourceEqualV2_1>;
+using BlacklistedConstellationSetV2_1 = std::unordered_set<V2_0::GnssConstellationType>;
 
 struct GnssConfiguration : public IGnssConfiguration {
     // Methods from ::android::hardware::gnss::V1_0::IGnssConfiguration follow.
@@ -78,7 +70,7 @@
     Return<bool> setBlacklist_2_1(
             const hidl_vec<V2_1::IGnssConfiguration::BlacklistedSource>& blacklist) override;
 
-    Return<bool> isBlacklistedV2_1(const GnssSvInfoV2_1& gnssSvInfo) const;
+    Return<bool> isBlacklistedV2_1(const V2_1::IGnssCallback::GnssSvInfo& gnssSvInfo) const;
 
   private:
     mutable std::recursive_mutex mMutex;
diff --git a/gnss/common/utils/default/include/v2_1/GnssDebug.h b/gnss/common/utils/default/include/v2_1/GnssDebug.h
index 8580989..481de59 100644
--- a/gnss/common/utils/default/include/v2_1/GnssDebug.h
+++ b/gnss/common/utils/default/include/v2_1/GnssDebug.h
@@ -21,15 +21,8 @@
 
 namespace android::hardware::gnss::V1_1::implementation {
 
-using ::android::sp;
-using ::android::hardware::hidl_string;
-using ::android::hardware::hidl_vec;
-using ::android::hardware::Return;
-using ::android::hardware::Void;
-using V1_0::IGnssDebug;
-
 /* Interface for GNSS Debug support. */
-struct GnssDebug : public IGnssDebug {
+struct GnssDebug : public V1_0::IGnssDebug {
     /*
      * Methods from ::android::hardware::gnss::V1_0::IGnssDebug follow.
      * These declarations were generated from IGnssDebug.hal.
diff --git a/gnss/common/utils/default/include/v2_1/GnssMeasurement.h b/gnss/common/utils/default/include/v2_1/GnssMeasurement.h
index 1d1fc9d..db8407b 100644
--- a/gnss/common/utils/default/include/v2_1/GnssMeasurement.h
+++ b/gnss/common/utils/default/include/v2_1/GnssMeasurement.h
@@ -25,17 +25,6 @@
 
 namespace android::hardware::gnss::V2_1::implementation {
 
-using GnssDataV2_1 = V2_1::IGnssMeasurementCallback::GnssData;
-using GnssDataV2_0 = V2_0::IGnssMeasurementCallback::GnssData;
-
-using ::android::sp;
-using ::android::hardware::hidl_array;
-using ::android::hardware::hidl_memory;
-using ::android::hardware::hidl_string;
-using ::android::hardware::hidl_vec;
-using ::android::hardware::Return;
-using ::android::hardware::Void;
-
 struct GnssMeasurement : public IGnssMeasurement {
     GnssMeasurement();
     ~GnssMeasurement();
@@ -59,8 +48,8 @@
   private:
     void start();
     void stop();
-    void reportMeasurement(const GnssDataV2_0&);
-    void reportMeasurement(const GnssDataV2_1&);
+    void reportMeasurement(const V2_0::IGnssMeasurementCallback::GnssData&);
+    void reportMeasurement(const V2_1::IGnssMeasurementCallback::GnssData&);
 
     // Guarded by mMutex
     static sp<V2_1::IGnssMeasurementCallback> sCallback_2_1;
diff --git a/gnss/common/utils/default/include/v2_1/GnssMeasurementCorrections.h b/gnss/common/utils/default/include/v2_1/GnssMeasurementCorrections.h
index eaa7659..54045ad 100644
--- a/gnss/common/utils/default/include/v2_1/GnssMeasurementCorrections.h
+++ b/gnss/common/utils/default/include/v2_1/GnssMeasurementCorrections.h
@@ -22,9 +22,6 @@
 
 namespace android::hardware::gnss::measurement_corrections::V1_1::implementation {
 
-using ::android::sp;
-using ::android::hardware::Return;
-
 struct GnssMeasurementCorrections : public IMeasurementCorrections {
     GnssMeasurementCorrections();
     ~GnssMeasurementCorrections();
diff --git a/gnss/common/utils/default/include/v2_1/GnssTemplate.h b/gnss/common/utils/default/include/v2_1/GnssTemplate.h
index 4d1baa7..4d4ec93 100644
--- a/gnss/common/utils/default/include/v2_1/GnssTemplate.h
+++ b/gnss/common/utils/default/include/v2_1/GnssTemplate.h
@@ -39,16 +39,6 @@
 
 namespace android::hardware::gnss::common::implementation {
 
-using GnssSvInfo = V2_1::IGnssCallback::GnssSvInfo;
-
-using common::NmeaFixInfo;
-using common::Utils;
-using measurement_corrections::V1_1::implementation::GnssMeasurementCorrections;
-
-using V2_1::implementation::GnssAntennaInfo;
-using V2_1::implementation::GnssConfiguration;
-using V2_1::implementation::GnssMeasurement;
-
 constexpr int INPUT_BUFFER_SIZE = 128;
 constexpr char CMD_GET_LOCATION[] = "CMD_GET_LOCATION";
 constexpr char GNSS_PATH[] = "/dev/gnss0";
@@ -120,7 +110,7 @@
     std::unique_ptr<V2_0::GnssLocation> getLocationFromHW();
     void reportLocation(const V2_0::GnssLocation&) const;
     void reportLocation(const V1_0::GnssLocation&) const;
-    void reportSvStatus(const hidl_vec<GnssSvInfo>&) const;
+    void reportSvStatus(const hidl_vec<V2_1::IGnssCallback::GnssSvInfo>&) const;
 
     Return<void> help(const hidl_handle& fd);
     Return<void> setLocation(const hidl_handle& fd, const hidl_vec<hidl_string>& options);
@@ -131,15 +121,15 @@
     static sp<V1_0::IGnssCallback> sGnssCallback_1_0;
 
     std::atomic<long> mMinIntervalMs;
-    sp<GnssConfiguration> mGnssConfiguration;
+    sp<V2_1::implementation::GnssConfiguration> mGnssConfiguration;
     std::atomic<bool> mIsActive;
     std::atomic<bool> mHardwareModeChecked;
     std::atomic<int> mGnssFd;
     std::thread mThread;
 
     mutable std::mutex mMutex;
-    virtual hidl_vec<GnssSvInfo> filterBlocklistedSatellitesV2_1(
-            hidl_vec<GnssSvInfo> gnssSvInfoList);
+    virtual hidl_vec<V2_1::IGnssCallback::GnssSvInfo> filterBlocklistedSatellitesV2_1(
+            hidl_vec<V2_1::IGnssCallback::GnssSvInfo> gnssSvInfoList);
 };
 
 template <class T_IGnss>
@@ -154,7 +144,7 @@
 template <class T_IGnss>
 GnssTemplate<T_IGnss>::GnssTemplate()
     : mMinIntervalMs(1000),
-      mGnssConfiguration{new GnssConfiguration()},
+      mGnssConfiguration{new V2_1::implementation::GnssConfiguration()},
       mHardwareModeChecked(false),
       mGnssFd(-1) {}
 
@@ -237,8 +227,8 @@
 }
 
 template <class T_IGnss>
-hidl_vec<GnssSvInfo> GnssTemplate<T_IGnss>::filterBlocklistedSatellitesV2_1(
-        hidl_vec<GnssSvInfo> gnssSvInfoList) {
+hidl_vec<V2_1::IGnssCallback::GnssSvInfo> GnssTemplate<T_IGnss>::filterBlocklistedSatellitesV2_1(
+        hidl_vec<V2_1::IGnssCallback::GnssSvInfo> gnssSvInfoList) {
     ALOGD("filterBlocklistedSatellitesV2_1");
     for (uint32_t i = 0; i < gnssSvInfoList.size(); i++) {
         if (mGnssConfiguration->isBlacklistedV2_1(gnssSvInfoList[i])) {
@@ -348,7 +338,7 @@
 template <class T_IGnss>
 Return<sp<V1_0::IGnssMeasurement>> GnssTemplate<T_IGnss>::getExtensionGnssMeasurement() {
     ALOGD("Gnss::getExtensionGnssMeasurement");
-    return new GnssMeasurement();
+    return new V2_1::implementation::GnssMeasurement();
 }
 
 template <class T_IGnss>
@@ -501,14 +491,14 @@
 template <class T_IGnss>
 Return<sp<V2_0::IGnssMeasurement>> GnssTemplate<T_IGnss>::getExtensionGnssMeasurement_2_0() {
     ALOGD("Gnss::getExtensionGnssMeasurement_2_0");
-    return new GnssMeasurement();
+    return new V2_1::implementation::GnssMeasurement();
 }
 
 template <class T_IGnss>
 Return<sp<measurement_corrections::V1_0::IMeasurementCorrections>>
 GnssTemplate<T_IGnss>::getExtensionMeasurementCorrections() {
     ALOGD("Gnss::getExtensionMeasurementCorrections()");
-    return new GnssMeasurementCorrections();
+    return new measurement_corrections::V1_1::implementation::GnssMeasurementCorrections();
 }
 
 template <class T_IGnss>
@@ -569,7 +559,7 @@
 template <class T_IGnss>
 Return<sp<V2_1::IGnssMeasurement>> GnssTemplate<T_IGnss>::getExtensionGnssMeasurement_2_1() {
     ALOGD("Gnss::getExtensionGnssMeasurement_2_1");
-    return new GnssMeasurement();
+    return new V2_1::implementation::GnssMeasurement();
 }
 
 template <class T_IGnss>
@@ -582,17 +572,18 @@
 Return<sp<measurement_corrections::V1_1::IMeasurementCorrections>>
 GnssTemplate<T_IGnss>::getExtensionMeasurementCorrections_1_1() {
     ALOGD("Gnss::getExtensionMeasurementCorrections_1_1()");
-    return new GnssMeasurementCorrections();
+    return new measurement_corrections::V1_1::implementation::GnssMeasurementCorrections();
 }
 
 template <class T_IGnss>
 Return<sp<V2_1::IGnssAntennaInfo>> GnssTemplate<T_IGnss>::getExtensionGnssAntennaInfo() {
     ALOGD("Gnss::getExtensionGnssAntennaInfo");
-    return new GnssAntennaInfo();
+    return new V2_1::implementation::GnssAntennaInfo();
 }
 
 template <class T_IGnss>
-void GnssTemplate<T_IGnss>::reportSvStatus(const hidl_vec<GnssSvInfo>& svInfoList) const {
+void GnssTemplate<T_IGnss>::reportSvStatus(
+        const hidl_vec<V2_1::IGnssCallback::GnssSvInfo>& svInfoList) const {
     std::unique_lock<std::mutex> lock(mMutex);
     // TODO(skz): update this to call 2_0 callback if non-null
     if (sGnssCallback_2_1 == nullptr) {
diff --git a/gnss/common/utils/default/v2_1/GnssConfiguration.cpp b/gnss/common/utils/default/v2_1/GnssConfiguration.cpp
index 8b30701..be974bc 100644
--- a/gnss/common/utils/default/v2_1/GnssConfiguration.cpp
+++ b/gnss/common/utils/default/v2_1/GnssConfiguration.cpp
@@ -21,6 +21,9 @@
 
 namespace android::hardware::gnss::V2_1::implementation {
 
+using GnssSvInfoV2_1 = V2_1::IGnssCallback::GnssSvInfo;
+using BlacklistedSourceV2_1 = V2_1::IGnssConfiguration::BlacklistedSource;
+
 // Methods from ::android::hardware::gnss::V1_0::IGnssConfiguration follow.
 Return<bool> GnssConfiguration::setSuplEs(bool enable) {
     ALOGD("setSuplEs enable: %d", enable);
@@ -69,7 +72,7 @@
 
 // Methods from ::android::hardware::gnss::V2_1::IGnssConfiguration follow.
 Return<bool> GnssConfiguration::setBlacklist_2_1(
-        const hidl_vec<V2_1::IGnssConfiguration::BlacklistedSource>& sourceList) {
+        const hidl_vec<BlacklistedSourceV2_1>& sourceList) {
     std::unique_lock<std::recursive_mutex> lock(mMutex);
     mBlacklistedConstellationSet.clear();
     mBlacklistedSourceSet.clear();
diff --git a/gnss/common/utils/default/v2_1/GnssMeasurement.cpp b/gnss/common/utils/default/v2_1/GnssMeasurement.cpp
index 7d3a002..887cb5a 100644
--- a/gnss/common/utils/default/v2_1/GnssMeasurement.cpp
+++ b/gnss/common/utils/default/v2_1/GnssMeasurement.cpp
@@ -114,7 +114,7 @@
     }
 }
 
-void GnssMeasurement::reportMeasurement(const GnssDataV2_0& data) {
+void GnssMeasurement::reportMeasurement(const V2_0::IGnssMeasurementCallback::GnssData& data) {
     ALOGD("reportMeasurement()");
     std::unique_lock<std::mutex> lock(mMutex);
     if (sCallback_2_0 == nullptr) {
@@ -127,7 +127,7 @@
     }
 }
 
-void GnssMeasurement::reportMeasurement(const GnssDataV2_1& data) {
+void GnssMeasurement::reportMeasurement(const V2_1::IGnssMeasurementCallback::GnssData& data) {
     ALOGD("reportMeasurement()");
     std::unique_lock<std::mutex> lock(mMutex);
     if (sCallback_2_1 == nullptr) {
diff --git a/gnss/common/utils/vts/include/v2_1/gnss_hal_test_template.h b/gnss/common/utils/vts/include/v2_1/gnss_hal_test_template.h
index 1439158..fec3503 100644
--- a/gnss/common/utils/vts/include/v2_1/gnss_hal_test_template.h
+++ b/gnss/common/utils/vts/include/v2_1/gnss_hal_test_template.h
@@ -23,36 +23,10 @@
 #include <gtest/gtest.h>
 #include <chrono>
 
-using ::android::hardware::gnss::common::Utils;
-
-using android::hardware::hidl_vec;
-using android::hardware::Return;
-using android::hardware::Void;
-
-using android::hardware::gnss::common::GnssCallback;
-using android::hardware::gnss::common::GnssCallbackEventQueue;
-using android::hardware::gnss::measurement_corrections::V1_0::IMeasurementCorrectionsCallback;
-using android::hardware::gnss::V1_0::GnssLocationFlags;
-using android::hardware::gnss::V2_0::GnssConstellationType;
-using android::hardware::gnss::V2_1::IGnssAntennaInfo;
-using android::hardware::gnss::V2_1::IGnssAntennaInfoCallback;
-
-using GnssLocation_1_0 = android::hardware::gnss::V1_0::GnssLocation;
-using GnssLocation_2_0 = android::hardware::gnss::V2_0::GnssLocation;
-
-using IGnssCallback_1_0 = android::hardware::gnss::V1_0::IGnssCallback;
-using IGnssCallback_2_0 = android::hardware::gnss::V2_0::IGnssCallback;
-using IGnssCallback_2_1 = android::hardware::gnss::V2_1::IGnssCallback;
-
-using IGnssMeasurementCallback_1_0 = android::hardware::gnss::V1_0::IGnssMeasurementCallback;
-using IGnssMeasurementCallback_1_1 = android::hardware::gnss::V1_1::IGnssMeasurementCallback;
-using IGnssMeasurementCallback_2_0 = android::hardware::gnss::V2_0::IGnssMeasurementCallback;
-using IGnssMeasurementCallback_2_1 = android::hardware::gnss::V2_1::IGnssMeasurementCallback;
-
-using android::sp;
-
 #define TIMEOUT_SEC 2  // for basic commands/responses
 
+namespace android::hardware::gnss::common {
+
 // The main test class for GNSS HAL.
 template <class T_IGnss>
 class GnssHalTestTemplate : public testing::TestWithParam<std::string> {
@@ -62,34 +36,37 @@
     virtual void TearDown() override;
 
     /* Callback class for GnssMeasurement. */
-    class GnssMeasurementCallback : public IGnssMeasurementCallback_2_1 {
+    class GnssMeasurementCallback : public V2_1::IGnssMeasurementCallback {
       public:
-        GnssCallbackEventQueue<IGnssMeasurementCallback_2_1::GnssData> measurement_cbq_;
+        GnssCallbackEventQueue<V2_1::IGnssMeasurementCallback::GnssData> measurement_cbq_;
 
         GnssMeasurementCallback() : measurement_cbq_("measurement"){};
         virtual ~GnssMeasurementCallback() = default;
 
         // Methods from V1_0::IGnssMeasurementCallback follow.
-        Return<void> GnssMeasurementCb(const IGnssMeasurementCallback_1_0::GnssData&) override {
+        Return<void> GnssMeasurementCb(const V1_0::IGnssMeasurementCallback::GnssData&) override {
             return Void();
         }
 
         // Methods from V1_1::IGnssMeasurementCallback follow.
-        Return<void> gnssMeasurementCb(const IGnssMeasurementCallback_1_1::GnssData&) override {
+        Return<void> gnssMeasurementCb(const V1_1::IGnssMeasurementCallback::GnssData&) override {
             return Void();
         }
 
         // Methods from V2_0::IGnssMeasurementCallback follow.
-        Return<void> gnssMeasurementCb_2_0(const IGnssMeasurementCallback_2_0::GnssData&) override {
+        Return<void> gnssMeasurementCb_2_0(
+                const V2_0::IGnssMeasurementCallback::GnssData&) override {
             return Void();
         }
 
         // Methods from V2_1::IGnssMeasurementCallback follow.
-        Return<void> gnssMeasurementCb_2_1(const IGnssMeasurementCallback_2_1::GnssData&) override;
+        Return<void> gnssMeasurementCb_2_1(
+                const V2_1::IGnssMeasurementCallback::GnssData&) override;
     };
 
     /* Callback class for GnssMeasurementCorrections. */
-    class GnssMeasurementCorrectionsCallback : public IMeasurementCorrectionsCallback {
+    class GnssMeasurementCorrectionsCallback
+        : public measurement_corrections::V1_0::IMeasurementCorrectionsCallback {
       public:
         uint32_t last_capabilities_;
         GnssCallbackEventQueue<uint32_t> capabilities_cbq_;
@@ -102,9 +79,9 @@
     };
 
     /* Callback class for GnssAntennaInfo. */
-    class GnssAntennaInfoCallback : public IGnssAntennaInfoCallback {
+    class GnssAntennaInfoCallback : public V2_1::IGnssAntennaInfoCallback {
       public:
-        GnssCallbackEventQueue<hidl_vec<IGnssAntennaInfoCallback::GnssAntennaInfo>>
+        GnssCallbackEventQueue<hidl_vec<V2_1::IGnssAntennaInfoCallback::GnssAntennaInfo>>
                 antenna_info_cbq_;
 
         GnssAntennaInfoCallback() : antenna_info_cbq_("info"){};
@@ -112,7 +89,7 @@
 
         // Methods from V2_1::GnssAntennaInfoCallback follow.
         Return<void> gnssAntennaInfoCb(
-                const hidl_vec<IGnssAntennaInfoCallback::GnssAntennaInfo>& gnssAntennaInfos);
+                const hidl_vec<V2_1::IGnssAntennaInfoCallback::GnssAntennaInfo>& gnssAntennaInfos);
     };
 
     /*
@@ -138,7 +115,7 @@
      *
      *   check_speed: true if speed related fields are also verified.
      */
-    void CheckLocation(const GnssLocation_2_0& location, const bool check_speed);
+    void CheckLocation(const V2_0::GnssLocation& location, const bool check_speed);
 
     /*
      * StartAndCheckLocations:
@@ -170,7 +147,7 @@
      * Note that location is not stopped in this method. The client should call
      * StopAndClearLocations() after the call.
      */
-    GnssConstellationType startLocationAndGetNonGpsConstellation(
+    V2_0::GnssConstellationType startLocationAndGetNonGpsConstellation(
             const int locations_to_await, const int gnss_sv_info_list_timeout);
 
     sp<T_IGnss> gnss_hal_;      // GNSS HAL to call into
@@ -283,7 +260,7 @@
 }
 
 template <class T_IGnss>
-void GnssHalTestTemplate<T_IGnss>::CheckLocation(const GnssLocation_2_0& location,
+void GnssHalTestTemplate<T_IGnss>::CheckLocation(const V2_0::GnssLocation& location,
                                                  bool check_speed) {
     const bool check_more_accuracies =
             (gnss_cb_->info_cbq_.calledCount() > 0 && gnss_cb_->last_info_.yearOfHw >= 2017);
@@ -315,7 +292,7 @@
 }
 
 template <class T_IGnss>
-GnssConstellationType GnssHalTestTemplate<T_IGnss>::startLocationAndGetNonGpsConstellation(
+V2_0::GnssConstellationType GnssHalTestTemplate<T_IGnss>::startLocationAndGetNonGpsConstellation(
         const int locations_to_await, const int gnss_sv_info_list_timeout) {
     gnss_cb_->location_cbq_.reset();
     StartAndCheckLocations(locations_to_await);
@@ -328,29 +305,29 @@
           sv_info_list_cbq_size, locations_to_await, location_called_count);
 
     // Find first non-GPS constellation to blacklist
-    GnssConstellationType constellation_to_blacklist = GnssConstellationType::UNKNOWN;
+    V2_0::GnssConstellationType constellation_to_blacklist = V2_0::GnssConstellationType::UNKNOWN;
     for (int i = 0; i < sv_info_list_cbq_size; ++i) {
-        hidl_vec<IGnssCallback_2_1::GnssSvInfo> sv_info_vec;
+        hidl_vec<V2_1::IGnssCallback::GnssSvInfo> sv_info_vec;
         gnss_cb_->sv_info_list_cbq_.retrieve(sv_info_vec, gnss_sv_info_list_timeout);
         for (uint32_t iSv = 0; iSv < sv_info_vec.size(); iSv++) {
             const auto& gnss_sv = sv_info_vec[iSv];
-            if ((gnss_sv.v2_0.v1_0.svFlag & IGnssCallback_1_0::GnssSvFlags::USED_IN_FIX) &&
-                (gnss_sv.v2_0.constellation != GnssConstellationType::UNKNOWN) &&
-                (gnss_sv.v2_0.constellation != GnssConstellationType::GPS)) {
+            if ((gnss_sv.v2_0.v1_0.svFlag & V1_0::IGnssCallback::GnssSvFlags::USED_IN_FIX) &&
+                (gnss_sv.v2_0.constellation != V2_0::GnssConstellationType::UNKNOWN) &&
+                (gnss_sv.v2_0.constellation != V2_0::GnssConstellationType::GPS)) {
                 // found a non-GPS constellation
                 constellation_to_blacklist = gnss_sv.v2_0.constellation;
                 break;
             }
         }
-        if (constellation_to_blacklist != GnssConstellationType::UNKNOWN) {
+        if (constellation_to_blacklist != V2_0::GnssConstellationType::UNKNOWN) {
             break;
         }
     }
 
-    if (constellation_to_blacklist == GnssConstellationType::UNKNOWN) {
+    if (constellation_to_blacklist == V2_0::GnssConstellationType::UNKNOWN) {
         ALOGI("No non-GPS constellations found, constellation blacklist test less effective.");
         // Proceed functionally to blacklist something.
-        constellation_to_blacklist = GnssConstellationType::GLONASS;
+        constellation_to_blacklist = V2_0::GnssConstellationType::GLONASS;
     }
 
     return constellation_to_blacklist;
@@ -358,7 +335,7 @@
 
 template <class T_IGnss>
 Return<void> GnssHalTestTemplate<T_IGnss>::GnssMeasurementCallback::gnssMeasurementCb_2_1(
-        const IGnssMeasurementCallback_2_1::GnssData& data) {
+        const V2_1::IGnssMeasurementCallback::GnssData& data) {
     ALOGD("GnssMeasurement v2.1 received. Size = %d", (int)data.measurements.size());
     measurement_cbq_.store(data);
     return Void();
@@ -374,8 +351,10 @@
 
 template <class T_IGnss>
 Return<void> GnssHalTestTemplate<T_IGnss>::GnssAntennaInfoCallback::gnssAntennaInfoCb(
-        const hidl_vec<IGnssAntennaInfoCallback::GnssAntennaInfo>& gnssAntennaInfos) {
+        const hidl_vec<V2_1::IGnssAntennaInfoCallback::GnssAntennaInfo>& gnssAntennaInfos) {
     ALOGD("GnssAntennaInfo v2.1 received. Size = %d", (int)gnssAntennaInfos.size());
     antenna_info_cbq_.store(gnssAntennaInfos);
     return Void();
 }
+
+}  // namespace android::hardware::gnss::common
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/support/authorization_set.cpp b/keymint/support/authorization_set.cpp
deleted file mode 100644
index 9fc4e13..0000000
--- a/keymint/support/authorization_set.cpp
+++ /dev/null
@@ -1,529 +0,0 @@
-/*
- * Copyright 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 <keymintSupport/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>
-
-namespace android {
-namespace hardware {
-namespace keymint {
-
-void AuthorizationSet::Sort() {
-    std::sort(data_.begin(), data_.end());
-}
-
-void AuthorizationSet::Deduplicate() {
-    if (data_.empty()) return;
-
-    Sort();
-    std::vector<KeyParameter> result;
-
-    auto curr = data_.begin();
-    auto prev = curr++;
-    for (; curr != data_.end(); ++prev, ++curr) {
-        if (prev->tag == Tag::INVALID) continue;
-
-        if (*prev != *curr) {
-            result.push_back(std::move(*prev));
-        }
-    }
-    result.push_back(std::move(*prev));
-
-    std::swap(data_, result);
-}
-
-void AuthorizationSet::Union(const AuthorizationSet& other) {
-    data_.insert(data_.end(), other.data_.begin(), other.data_.end());
-    Deduplicate();
-}
-
-void AuthorizationSet::Subtract(const AuthorizationSet& other) {
-    Deduplicate();
-
-    auto i = other.begin();
-    while (i != other.end()) {
-        int pos = -1;
-        do {
-            pos = find(i->tag, pos);
-            if (pos != -1 && (*i == data_[pos])) {
-                data_.erase(data_.begin() + pos);
-                break;
-            }
-        } while (pos != -1);
-        ++i;
-    }
-}
-
-void AuthorizationSet::Filter(std::function<bool(const KeyParameter&)> doKeep) {
-    std::vector<KeyParameter> result;
-    for (auto& param : data_) {
-        if (doKeep(param)) {
-            result.push_back(std::move(param));
-        }
-    }
-    std::swap(data_, result);
-}
-
-KeyParameter& AuthorizationSet::operator[](int at) {
-    return data_[at];
-}
-
-const KeyParameter& AuthorizationSet::operator[](int at) const {
-    return data_[at];
-}
-
-void AuthorizationSet::Clear() {
-    data_.clear();
-}
-
-size_t AuthorizationSet::GetTagCount(Tag tag) const {
-    size_t count = 0;
-    for (int pos = -1; (pos = find(tag, pos)) != -1;) ++count;
-    return count;
-}
-
-int AuthorizationSet::find(Tag tag, int begin) const {
-    auto iter = data_.begin() + (1 + begin);
-
-    while (iter != data_.end() && iter->tag != tag) ++iter;
-
-    if (iter != data_.end()) return iter - data_.begin();
-    return -1;
-}
-
-bool AuthorizationSet::erase(int index) {
-    auto pos = data_.begin() + index;
-    if (pos != data_.end()) {
-        data_.erase(pos);
-        return true;
-    }
-    return false;
-}
-
-NullOr<const KeyParameter&> AuthorizationSet::GetEntry(Tag tag) const {
-    int pos = find(tag);
-    if (pos == -1) return {};
-    return data_[pos];
-}
-
-/**
- * Persistent format is:
- * | 32 bit indirect_size         |
- * --------------------------------
- * | indirect_size bytes of data  | this is where the blob data is stored
- * --------------------------------
- * | 32 bit element_count         | number of entries
- * | 32 bit elements_size         | total bytes used by entries (entries have variable length)
- * --------------------------------
- * | elementes_size bytes of data | where the elements are stored
- */
-
-/**
- * Persistent format of blobs and bignums:
- * | 32 bit tag             |
- * | 32 bit blob_length     |
- * | 32 bit indirect_offset |
- */
-
-struct OutStreams {
-    std::ostream& indirect;
-    std::ostream& elements;
-    size_t skipped;
-};
-
-OutStreams& serializeParamValue(OutStreams& out, const vector<uint8_t>& blob) {
-    uint32_t buffer;
-
-    // write blob_length
-    auto blob_length = blob.size();
-    if (blob_length > std::numeric_limits<uint32_t>::max()) {
-        out.elements.setstate(std::ios_base::badbit);
-        return out;
-    }
-    buffer = blob_length;
-    out.elements.write(reinterpret_cast<const char*>(&buffer), sizeof(uint32_t));
-
-    // write indirect_offset
-    auto offset = out.indirect.tellp();
-    if (offset < 0 || offset > std::numeric_limits<uint32_t>::max() ||
-        uint32_t(offset) + uint32_t(blob_length) < uint32_t(offset)) {  // overflow check
-        out.elements.setstate(std::ios_base::badbit);
-        return out;
-    }
-    buffer = offset;
-    out.elements.write(reinterpret_cast<const char*>(&buffer), sizeof(uint32_t));
-
-    // write blob to indirect stream
-    if (blob_length) out.indirect.write(reinterpret_cast<const char*>(&blob[0]), blob_length);
-
-    return out;
-}
-
-template <typename T>
-OutStreams& serializeParamValue(OutStreams& out, const T& value) {
-    out.elements.write(reinterpret_cast<const char*>(&value), sizeof(T));
-    return out;
-}
-
-OutStreams& serialize(TAG_INVALID_t&&, OutStreams& out, const KeyParameter&) {
-    // skip invalid entries.
-    ++out.skipped;
-    return out;
-}
-template <typename T>
-OutStreams& serialize(T ttag, OutStreams& out, const KeyParameter& param) {
-    out.elements.write(reinterpret_cast<const char*>(&param.tag), sizeof(int32_t));
-    return serializeParamValue(out, accessTagValue(ttag, param));
-}
-
-template <typename... T>
-struct choose_serializer;
-template <typename... Tags>
-struct choose_serializer<MetaList<Tags...>> {
-    static OutStreams& serialize(OutStreams& out, const KeyParameter& param) {
-        return choose_serializer<Tags...>::serialize(out, param);
-    }
-};
-
-template <>
-struct choose_serializer<> {
-    static OutStreams& serialize(OutStreams& out, const KeyParameter& param) {
-        LOG(WARNING) << "Trying to serialize unknown tag " << unsigned(param.tag)
-                     << ". Did you forget to add it to all_tags_t?";
-        ++out.skipped;
-        return out;
-    }
-};
-
-template <TagType tag_type, Tag tag, typename... Tail>
-struct choose_serializer<android::hardware::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);
-        } else {
-            return choose_serializer<Tail...>::serialize(out, param);
-        }
-    }
-};
-
-OutStreams& serialize(OutStreams& out, const KeyParameter& param) {
-    return choose_serializer<all_tags_t>::serialize(out, param);
-}
-
-std::ostream& serialize(std::ostream& out, const std::vector<KeyParameter>& params) {
-    std::stringstream indirect;
-    std::stringstream elements;
-    OutStreams streams = {indirect, elements, 0};
-    for (const auto& param : params) {
-        serialize(streams, param);
-    }
-    if (indirect.bad() || elements.bad()) {
-        out.setstate(std::ios_base::badbit);
-        return out;
-    }
-    auto pos = indirect.tellp();
-    if (pos < 0 || pos > std::numeric_limits<uint32_t>::max()) {
-        out.setstate(std::ios_base::badbit);
-        return out;
-    }
-    uint32_t indirect_size = pos;
-    pos = elements.tellp();
-    if (pos < 0 || pos > std::numeric_limits<uint32_t>::max()) {
-        out.setstate(std::ios_base::badbit);
-        return out;
-    }
-    uint32_t elements_size = pos;
-    uint32_t element_count = params.size() - streams.skipped;
-
-    out.write(reinterpret_cast<const char*>(&indirect_size), sizeof(uint32_t));
-
-    pos = out.tellp();
-    if (indirect_size) out << indirect.rdbuf();
-    assert(out.tellp() - pos == indirect_size);
-
-    out.write(reinterpret_cast<const char*>(&element_count), sizeof(uint32_t));
-    out.write(reinterpret_cast<const char*>(&elements_size), sizeof(uint32_t));
-
-    pos = out.tellp();
-    if (elements_size) out << elements.rdbuf();
-    assert(out.tellp() - pos == elements_size);
-
-    return out;
-}
-
-struct InStreams {
-    std::istream& indirect;
-    std::istream& elements;
-    size_t invalids;
-};
-
-InStreams& deserializeParamValue(InStreams& in, vector<uint8_t>* blob) {
-    uint32_t blob_length = 0;
-    uint32_t offset = 0;
-    in.elements.read(reinterpret_cast<char*>(&blob_length), sizeof(uint32_t));
-    blob->resize(blob_length);
-    in.elements.read(reinterpret_cast<char*>(&offset), sizeof(uint32_t));
-    in.indirect.seekg(offset);
-    in.indirect.read(reinterpret_cast<char*>(&(*blob)[0]), blob->size());
-    return in;
-}
-
-template <typename T>
-InStreams& deserializeParamValue(InStreams& in, T* value) {
-    in.elements.read(reinterpret_cast<char*>(value), sizeof(T));
-    return in;
-}
-
-InStreams& deserialize(TAG_INVALID_t&&, InStreams& in, KeyParameter*) {
-    // there should be no invalid KeyParameters but if handle them as zero sized.
-    ++in.invalids;
-    return in;
-}
-
-template <typename T>
-InStreams& deserialize(T&& ttag, InStreams& in, KeyParameter* param) {
-    return deserializeParamValue(in, &accessTagValue(ttag, *param));
-}
-
-template <typename... T>
-struct choose_deserializer;
-template <typename... Tags>
-struct choose_deserializer<MetaList<Tags...>> {
-    static InStreams& deserialize(InStreams& in, KeyParameter* param) {
-        return choose_deserializer<Tags...>::deserialize(in, param);
-    }
-};
-template <>
-struct choose_deserializer<> {
-    static InStreams& deserialize(InStreams& in, KeyParameter*) {
-        // encountered an unknown tag -> fail parsing
-        in.elements.setstate(std::ios_base::badbit);
-        return in;
-    }
-};
-template <TagType tag_type, Tag tag, typename... Tail>
-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);
-        } else {
-            return choose_deserializer<Tail...>::deserialize(in, param);
-        }
-    }
-};
-
-InStreams& deserialize(InStreams& in, KeyParameter* param) {
-    in.elements.read(reinterpret_cast<char*>(&param->tag), sizeof(Tag));
-    return choose_deserializer<all_tags_t>::deserialize(in, param);
-}
-
-std::istream& deserialize(std::istream& in, std::vector<KeyParameter>* params) {
-    uint32_t indirect_size = 0;
-    in.read(reinterpret_cast<char*>(&indirect_size), sizeof(uint32_t));
-    std::string indirect_buffer(indirect_size, '\0');
-    if (indirect_buffer.size() != indirect_size) {
-        in.setstate(std::ios_base::badbit);
-        return in;
-    }
-    in.read(&indirect_buffer[0], indirect_buffer.size());
-
-    uint32_t element_count = 0;
-    in.read(reinterpret_cast<char*>(&element_count), sizeof(uint32_t));
-    uint32_t elements_size = 0;
-    in.read(reinterpret_cast<char*>(&elements_size), sizeof(uint32_t));
-
-    std::string elements_buffer(elements_size, '\0');
-    if (elements_buffer.size() != elements_size) {
-        in.setstate(std::ios_base::badbit);
-        return in;
-    }
-    in.read(&elements_buffer[0], elements_buffer.size());
-
-    if (in.bad()) return in;
-
-    // TODO write one-shot stream buffer to avoid copying here
-    std::stringstream indirect(indirect_buffer);
-    std::stringstream elements(elements_buffer);
-    InStreams streams = {indirect, elements, 0};
-
-    params->resize(element_count);
-
-    for (uint32_t i = 0; i < element_count; ++i) {
-        deserialize(streams, &(*params)[i]);
-    }
-
-    /*
-     * There are legacy blobs which have invalid tags in them due to a bug during serialization.
-     * This makes sure that invalid tags are filtered from the result before it is returned.
-     */
-    if (streams.invalids > 0) {
-        std::vector<KeyParameter> filtered(element_count - streams.invalids);
-        auto ifiltered = filtered.begin();
-        for (auto& p : *params) {
-            if (p.tag != Tag::INVALID) {
-                *ifiltered++ = std::move(p);
-            }
-        }
-        *params = std::move(filtered);
-    }
-    return in;
-}
-
-void AuthorizationSet::Serialize(std::ostream* out) const {
-    serialize(*out, data_);
-}
-
-void AuthorizationSet::Deserialize(std::istream* in) {
-    deserialize(*in, &data_);
-}
-
-AuthorizationSetBuilder& AuthorizationSetBuilder::RsaKey(uint32_t key_size,
-                                                         uint64_t public_exponent) {
-    Authorization(TAG_ALGORITHM, Algorithm::RSA);
-    Authorization(TAG_KEY_SIZE, key_size);
-    Authorization(TAG_RSA_PUBLIC_EXPONENT, public_exponent);
-    return *this;
-}
-
-AuthorizationSetBuilder& AuthorizationSetBuilder::EcdsaKey(uint32_t key_size) {
-    Authorization(TAG_ALGORITHM, Algorithm::EC);
-    Authorization(TAG_KEY_SIZE, key_size);
-    return *this;
-}
-
-AuthorizationSetBuilder& AuthorizationSetBuilder::EcdsaKey(EcCurve curve) {
-    Authorization(TAG_ALGORITHM, Algorithm::EC);
-    Authorization(TAG_EC_CURVE, curve);
-    return *this;
-}
-
-AuthorizationSetBuilder& AuthorizationSetBuilder::AesKey(uint32_t key_size) {
-    Authorization(TAG_ALGORITHM, Algorithm::AES);
-    return Authorization(TAG_KEY_SIZE, key_size);
-}
-
-AuthorizationSetBuilder& AuthorizationSetBuilder::TripleDesKey(uint32_t key_size) {
-    Authorization(TAG_ALGORITHM, Algorithm::TRIPLE_DES);
-    return Authorization(TAG_KEY_SIZE, key_size);
-}
-
-AuthorizationSetBuilder& AuthorizationSetBuilder::HmacKey(uint32_t key_size) {
-    Authorization(TAG_ALGORITHM, Algorithm::HMAC);
-    Authorization(TAG_KEY_SIZE, key_size);
-    return SigningKey();
-}
-
-AuthorizationSetBuilder& AuthorizationSetBuilder::RsaSigningKey(uint32_t key_size,
-                                                                uint64_t public_exponent) {
-    RsaKey(key_size, public_exponent);
-    return SigningKey();
-}
-
-AuthorizationSetBuilder& AuthorizationSetBuilder::RsaEncryptionKey(uint32_t key_size,
-                                                                   uint64_t public_exponent) {
-    RsaKey(key_size, public_exponent);
-    return EncryptionKey();
-}
-
-AuthorizationSetBuilder& AuthorizationSetBuilder::EcdsaSigningKey(uint32_t key_size) {
-    EcdsaKey(key_size);
-    return SigningKey();
-}
-
-AuthorizationSetBuilder& AuthorizationSetBuilder::EcdsaSigningKey(EcCurve curve) {
-    EcdsaKey(curve);
-    return SigningKey();
-}
-
-AuthorizationSetBuilder& AuthorizationSetBuilder::AesEncryptionKey(uint32_t key_size) {
-    AesKey(key_size);
-    return EncryptionKey();
-}
-
-AuthorizationSetBuilder& AuthorizationSetBuilder::TripleDesEncryptionKey(uint32_t key_size) {
-    TripleDesKey(key_size);
-    return EncryptionKey();
-}
-
-AuthorizationSetBuilder& AuthorizationSetBuilder::SigningKey() {
-    Authorization(TAG_PURPOSE, KeyPurpose::SIGN);
-    return Authorization(TAG_PURPOSE, KeyPurpose::VERIFY);
-}
-
-AuthorizationSetBuilder& AuthorizationSetBuilder::EncryptionKey() {
-    Authorization(TAG_PURPOSE, KeyPurpose::ENCRYPT);
-    return Authorization(TAG_PURPOSE, KeyPurpose::DECRYPT);
-}
-
-AuthorizationSetBuilder& AuthorizationSetBuilder::NoDigestOrPadding() {
-    Authorization(TAG_DIGEST, Digest::NONE);
-    return Authorization(TAG_PADDING, PaddingMode::NONE);
-}
-
-AuthorizationSetBuilder& AuthorizationSetBuilder::EcbMode() {
-    return Authorization(TAG_BLOCK_MODE, BlockMode::ECB);
-}
-
-AuthorizationSetBuilder& AuthorizationSetBuilder::GcmModeMinMacLen(uint32_t minMacLength) {
-    return BlockMode(BlockMode::GCM)
-            .Padding(PaddingMode::NONE)
-            .Authorization(TAG_MIN_MAC_LENGTH, minMacLength);
-}
-
-AuthorizationSetBuilder& AuthorizationSetBuilder::GcmModeMacLen(uint32_t macLength) {
-    return BlockMode(BlockMode::GCM)
-            .Padding(PaddingMode::NONE)
-            .Authorization(TAG_MAC_LENGTH, macLength);
-}
-
-AuthorizationSetBuilder& AuthorizationSetBuilder::BlockMode(
-        std::initializer_list<android::hardware::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) {
-    for (auto digest : digests) {
-        push_back(TAG_DIGEST, digest);
-    }
-    return *this;
-}
-
-AuthorizationSetBuilder& AuthorizationSetBuilder::Padding(
-        std::initializer_list<PaddingMode> paddingModes) {
-    for (auto paddingMode : paddingModes) {
-        push_back(TAG_PADDING, paddingMode);
-    }
-    return *this;
-}
-
-}  // namespace keymint
-}  // namespace hardware
-}  // namespace android
diff --git a/neuralnetworks/1.0/utils/include/nnapi/hal/1.0/Callbacks.h b/neuralnetworks/1.0/utils/include/nnapi/hal/1.0/Callbacks.h
index 65b75e5..2e00fce 100644
--- a/neuralnetworks/1.0/utils/include/nnapi/hal/1.0/Callbacks.h
+++ b/neuralnetworks/1.0/utils/include/nnapi/hal/1.0/Callbacks.h
@@ -27,6 +27,9 @@
 #include <nnapi/hal/ProtectCallback.h>
 #include <nnapi/hal/TransferValue.h>
 
+// See hardware/interfaces/neuralnetworks/utils/README.md for more information on HIDL interface
+// lifetimes across processes and for protecting asynchronous calls across HIDL.
+
 namespace android::hardware::neuralnetworks::V1_0::utils {
 
 class PreparedModelCallback final : public IPreparedModelCallback,
diff --git a/neuralnetworks/1.0/utils/include/nnapi/hal/1.0/Device.h b/neuralnetworks/1.0/utils/include/nnapi/hal/1.0/Device.h
index ee103ba..db3b2ad 100644
--- a/neuralnetworks/1.0/utils/include/nnapi/hal/1.0/Device.h
+++ b/neuralnetworks/1.0/utils/include/nnapi/hal/1.0/Device.h
@@ -32,8 +32,12 @@
 #include <string>
 #include <vector>
 
+// See hardware/interfaces/neuralnetworks/utils/README.md for more information on HIDL interface
+// lifetimes across processes and for protecting asynchronous calls across HIDL.
+
 namespace android::hardware::neuralnetworks::V1_0::utils {
 
+// Class that adapts V1_0::IDevice to nn::IDevice.
 class Device final : public nn::IDevice {
     struct PrivateConstructorTag {};
 
diff --git a/neuralnetworks/1.0/utils/include/nnapi/hal/1.0/PreparedModel.h b/neuralnetworks/1.0/utils/include/nnapi/hal/1.0/PreparedModel.h
index 31f366d..2de1828 100644
--- a/neuralnetworks/1.0/utils/include/nnapi/hal/1.0/PreparedModel.h
+++ b/neuralnetworks/1.0/utils/include/nnapi/hal/1.0/PreparedModel.h
@@ -29,8 +29,12 @@
 #include <utility>
 #include <vector>
 
+// See hardware/interfaces/neuralnetworks/utils/README.md for more information on HIDL interface
+// lifetimes across processes and for protecting asynchronous calls across HIDL.
+
 namespace android::hardware::neuralnetworks::V1_0::utils {
 
+// Class that adapts V1_0::IPreparedModel to nn::IPreparedModel.
 class PreparedModel final : public nn::IPreparedModel {
     struct PrivateConstructorTag {};
 
@@ -44,13 +48,13 @@
     nn::ExecutionResult<std::pair<std::vector<nn::OutputShape>, nn::Timing>> execute(
             const nn::Request& request, nn::MeasureTiming measure,
             const nn::OptionalTimePoint& deadline,
-            const nn::OptionalTimeoutDuration& loopTimeoutDuration) const override;
+            const nn::OptionalDuration& loopTimeoutDuration) const override;
 
     nn::GeneralResult<std::pair<nn::SyncFence, nn::ExecuteFencedInfoCallback>> executeFenced(
             const nn::Request& request, const std::vector<nn::SyncFence>& waitFor,
             nn::MeasureTiming measure, const nn::OptionalTimePoint& deadline,
-            const nn::OptionalTimeoutDuration& loopTimeoutDuration,
-            const nn::OptionalTimeoutDuration& timeoutDurationAfterFence) const override;
+            const nn::OptionalDuration& loopTimeoutDuration,
+            const nn::OptionalDuration& timeoutDurationAfterFence) const override;
 
     std::any getUnderlyingResource() const override;
 
diff --git a/neuralnetworks/1.0/utils/src/Callbacks.cpp b/neuralnetworks/1.0/utils/src/Callbacks.cpp
index b1259c3..a0bdb3c 100644
--- a/neuralnetworks/1.0/utils/src/Callbacks.cpp
+++ b/neuralnetworks/1.0/utils/src/Callbacks.cpp
@@ -32,6 +32,9 @@
 
 #include <utility>
 
+// See hardware/interfaces/neuralnetworks/utils/README.md for more information on HIDL interface
+// lifetimes across processes and for protecting asynchronous calls across HIDL.
+
 namespace android::hardware::neuralnetworks::V1_0::utils {
 namespace {
 
diff --git a/neuralnetworks/1.0/utils/src/Device.cpp b/neuralnetworks/1.0/utils/src/Device.cpp
index 285c515..83e0015 100644
--- a/neuralnetworks/1.0/utils/src/Device.cpp
+++ b/neuralnetworks/1.0/utils/src/Device.cpp
@@ -38,6 +38,9 @@
 #include <string>
 #include <vector>
 
+// See hardware/interfaces/neuralnetworks/utils/README.md for more information on HIDL interface
+// lifetimes across processes and for protecting asynchronous calls across HIDL.
+
 namespace android::hardware::neuralnetworks::V1_0::utils {
 namespace {
 
diff --git a/neuralnetworks/1.0/utils/src/PreparedModel.cpp b/neuralnetworks/1.0/utils/src/PreparedModel.cpp
index 46dd3f8..c1dd1d9 100644
--- a/neuralnetworks/1.0/utils/src/PreparedModel.cpp
+++ b/neuralnetworks/1.0/utils/src/PreparedModel.cpp
@@ -34,6 +34,9 @@
 #include <utility>
 #include <vector>
 
+// See hardware/interfaces/neuralnetworks/utils/README.md for more information on HIDL interface
+// lifetimes across processes and for protecting asynchronous calls across HIDL.
+
 namespace android::hardware::neuralnetworks::V1_0::utils {
 
 nn::GeneralResult<std::shared_ptr<const PreparedModel>> PreparedModel::create(
@@ -55,7 +58,7 @@
 nn::ExecutionResult<std::pair<std::vector<nn::OutputShape>, nn::Timing>> PreparedModel::execute(
         const nn::Request& request, nn::MeasureTiming /*measure*/,
         const nn::OptionalTimePoint& /*deadline*/,
-        const nn::OptionalTimeoutDuration& /*loopTimeoutDuration*/) const {
+        const nn::OptionalDuration& /*loopTimeoutDuration*/) const {
     // Ensure that request is ready for IPC.
     std::optional<nn::Request> maybeRequestInShared;
     const nn::Request& requestInShared = NN_TRY(hal::utils::makeExecutionFailure(
@@ -81,11 +84,12 @@
 }
 
 nn::GeneralResult<std::pair<nn::SyncFence, nn::ExecuteFencedInfoCallback>>
-PreparedModel::executeFenced(
-        const nn::Request& /*request*/, const std::vector<nn::SyncFence>& /*waitFor*/,
-        nn::MeasureTiming /*measure*/, const nn::OptionalTimePoint& /*deadline*/,
-        const nn::OptionalTimeoutDuration& /*loopTimeoutDuration*/,
-        const nn::OptionalTimeoutDuration& /*timeoutDurationAfterFence*/) const {
+PreparedModel::executeFenced(const nn::Request& /*request*/,
+                             const std::vector<nn::SyncFence>& /*waitFor*/,
+                             nn::MeasureTiming /*measure*/,
+                             const nn::OptionalTimePoint& /*deadline*/,
+                             const nn::OptionalDuration& /*loopTimeoutDuration*/,
+                             const nn::OptionalDuration& /*timeoutDurationAfterFence*/) const {
     return NN_ERROR(nn::ErrorStatus::GENERAL_FAILURE)
            << "IPreparedModel::executeFenced is not supported on 1.0 HAL service";
 }
diff --git a/neuralnetworks/1.1/utils/include/nnapi/hal/1.1/Device.h b/neuralnetworks/1.1/utils/include/nnapi/hal/1.1/Device.h
index c1e95fe1a..5e224b5 100644
--- a/neuralnetworks/1.1/utils/include/nnapi/hal/1.1/Device.h
+++ b/neuralnetworks/1.1/utils/include/nnapi/hal/1.1/Device.h
@@ -32,8 +32,12 @@
 #include <string>
 #include <vector>
 
+// See hardware/interfaces/neuralnetworks/utils/README.md for more information on HIDL interface
+// lifetimes across processes and for protecting asynchronous calls across HIDL.
+
 namespace android::hardware::neuralnetworks::V1_1::utils {
 
+// Class that adapts V1_1::IDevice to nn::IDevice.
 class Device final : public nn::IDevice {
     struct PrivateConstructorTag {};
 
diff --git a/neuralnetworks/1.1/utils/src/Device.cpp b/neuralnetworks/1.1/utils/src/Device.cpp
index f73d3f8..b57c7f4 100644
--- a/neuralnetworks/1.1/utils/src/Device.cpp
+++ b/neuralnetworks/1.1/utils/src/Device.cpp
@@ -39,6 +39,9 @@
 #include <string>
 #include <vector>
 
+// See hardware/interfaces/neuralnetworks/utils/README.md for more information on HIDL interface
+// lifetimes across processes and for protecting asynchronous calls across HIDL.
+
 namespace android::hardware::neuralnetworks::V1_1::utils {
 namespace {
 
diff --git a/neuralnetworks/1.2/utils/include/nnapi/hal/1.2/Callbacks.h b/neuralnetworks/1.2/utils/include/nnapi/hal/1.2/Callbacks.h
index bc7d92a..1162bc3 100644
--- a/neuralnetworks/1.2/utils/include/nnapi/hal/1.2/Callbacks.h
+++ b/neuralnetworks/1.2/utils/include/nnapi/hal/1.2/Callbacks.h
@@ -31,6 +31,9 @@
 #include <nnapi/hal/ProtectCallback.h>
 #include <nnapi/hal/TransferValue.h>
 
+// See hardware/interfaces/neuralnetworks/utils/README.md for more information on HIDL interface
+// lifetimes across processes and for protecting asynchronous calls across HIDL.
+
 namespace android::hardware::neuralnetworks::V1_2::utils {
 
 class PreparedModelCallback final : public IPreparedModelCallback,
diff --git a/neuralnetworks/1.2/utils/include/nnapi/hal/1.2/Device.h b/neuralnetworks/1.2/utils/include/nnapi/hal/1.2/Device.h
index a68830d..79c3b04 100644
--- a/neuralnetworks/1.2/utils/include/nnapi/hal/1.2/Device.h
+++ b/neuralnetworks/1.2/utils/include/nnapi/hal/1.2/Device.h
@@ -32,6 +32,9 @@
 #include <string>
 #include <vector>
 
+// See hardware/interfaces/neuralnetworks/utils/README.md for more information on HIDL interface
+// lifetimes across processes and for protecting asynchronous calls across HIDL.
+
 namespace android::hardware::neuralnetworks::V1_2::utils {
 
 nn::GeneralResult<std::string> initVersionString(V1_2::IDevice* device);
@@ -40,6 +43,7 @@
 nn::GeneralResult<std::pair<uint32_t, uint32_t>> initNumberOfCacheFilesNeeded(
         V1_2::IDevice* device);
 
+// Class that adapts V1_2::IDevice to nn::IDevice.
 class Device final : public nn::IDevice {
     struct PrivateConstructorTag {};
 
diff --git a/neuralnetworks/1.2/utils/include/nnapi/hal/1.2/PreparedModel.h b/neuralnetworks/1.2/utils/include/nnapi/hal/1.2/PreparedModel.h
index 65e1e8a..8ed5ca7 100644
--- a/neuralnetworks/1.2/utils/include/nnapi/hal/1.2/PreparedModel.h
+++ b/neuralnetworks/1.2/utils/include/nnapi/hal/1.2/PreparedModel.h
@@ -30,8 +30,12 @@
 #include <utility>
 #include <vector>
 
+// See hardware/interfaces/neuralnetworks/utils/README.md for more information on HIDL interface
+// lifetimes across processes and for protecting asynchronous calls across HIDL.
+
 namespace android::hardware::neuralnetworks::V1_2::utils {
 
+// Class that adapts V1_2::IPreparedModel to nn::IPreparedModel.
 class PreparedModel final : public nn::IPreparedModel {
     struct PrivateConstructorTag {};
 
@@ -45,13 +49,13 @@
     nn::ExecutionResult<std::pair<std::vector<nn::OutputShape>, nn::Timing>> execute(
             const nn::Request& request, nn::MeasureTiming measure,
             const nn::OptionalTimePoint& deadline,
-            const nn::OptionalTimeoutDuration& loopTimeoutDuration) const override;
+            const nn::OptionalDuration& loopTimeoutDuration) const override;
 
     nn::GeneralResult<std::pair<nn::SyncFence, nn::ExecuteFencedInfoCallback>> executeFenced(
             const nn::Request& request, const std::vector<nn::SyncFence>& waitFor,
             nn::MeasureTiming measure, const nn::OptionalTimePoint& deadline,
-            const nn::OptionalTimeoutDuration& loopTimeoutDuration,
-            const nn::OptionalTimeoutDuration& timeoutDurationAfterFence) const override;
+            const nn::OptionalDuration& loopTimeoutDuration,
+            const nn::OptionalDuration& timeoutDurationAfterFence) const override;
 
     std::any getUnderlyingResource() const override;
 
diff --git a/neuralnetworks/1.2/utils/src/Callbacks.cpp b/neuralnetworks/1.2/utils/src/Callbacks.cpp
index 39f88c2..ab3e0ca 100644
--- a/neuralnetworks/1.2/utils/src/Callbacks.cpp
+++ b/neuralnetworks/1.2/utils/src/Callbacks.cpp
@@ -36,6 +36,9 @@
 
 #include <utility>
 
+// See hardware/interfaces/neuralnetworks/utils/README.md for more information on HIDL interface
+// lifetimes across processes and for protecting asynchronous calls across HIDL.
+
 namespace android::hardware::neuralnetworks::V1_2::utils {
 namespace {
 
diff --git a/neuralnetworks/1.2/utils/src/Conversions.cpp b/neuralnetworks/1.2/utils/src/Conversions.cpp
index f11474f..3790d1f 100644
--- a/neuralnetworks/1.2/utils/src/Conversions.cpp
+++ b/neuralnetworks/1.2/utils/src/Conversions.cpp
@@ -43,7 +43,9 @@
     return static_cast<std::underlying_type_t<Type>>(value);
 }
 
+using HalDuration = std::chrono::duration<uint64_t, std::micro>;
 constexpr auto kVersion = android::nn::Version::ANDROID_Q;
+constexpr uint64_t kNoTiming = std::numeric_limits<uint64_t>::max();
 
 }  // namespace
 
@@ -270,7 +272,18 @@
 }
 
 GeneralResult<Timing> unvalidatedConvert(const hal::V1_2::Timing& timing) {
-    return Timing{.timeOnDevice = timing.timeOnDevice, .timeInDriver = timing.timeInDriver};
+    constexpr uint64_t kMaxTiming = std::chrono::floor<HalDuration>(Duration::max()).count();
+    constexpr auto convertTiming = [](uint64_t halTiming) -> OptionalDuration {
+        if (halTiming == kNoTiming) {
+            return {};
+        }
+        if (halTiming > kMaxTiming) {
+            return Duration::max();
+        }
+        return HalDuration{halTiming};
+    };
+    return Timing{.timeOnDevice = convertTiming(timing.timeOnDevice),
+                  .timeInDriver = convertTiming(timing.timeInDriver)};
 }
 
 GeneralResult<Extension> unvalidatedConvert(const hal::V1_2::Extension& extension) {
@@ -547,7 +560,14 @@
 }
 
 nn::GeneralResult<Timing> unvalidatedConvert(const nn::Timing& timing) {
-    return Timing{.timeOnDevice = timing.timeOnDevice, .timeInDriver = timing.timeInDriver};
+    constexpr auto convertTiming = [](nn::OptionalDuration canonicalTiming) -> uint64_t {
+        if (!canonicalTiming.has_value()) {
+            return kNoTiming;
+        }
+        return std::chrono::ceil<HalDuration>(*canonicalTiming).count();
+    };
+    return Timing{.timeOnDevice = convertTiming(timing.timeOnDevice),
+                  .timeInDriver = convertTiming(timing.timeInDriver)};
 }
 
 nn::GeneralResult<Extension> unvalidatedConvert(const nn::Extension& extension) {
diff --git a/neuralnetworks/1.2/utils/src/Device.cpp b/neuralnetworks/1.2/utils/src/Device.cpp
index 0061065..6cca841 100644
--- a/neuralnetworks/1.2/utils/src/Device.cpp
+++ b/neuralnetworks/1.2/utils/src/Device.cpp
@@ -41,6 +41,9 @@
 #include <string>
 #include <vector>
 
+// See hardware/interfaces/neuralnetworks/utils/README.md for more information on HIDL interface
+// lifetimes across processes and for protecting asynchronous calls across HIDL.
+
 namespace android::hardware::neuralnetworks::V1_2::utils {
 namespace {
 
diff --git a/neuralnetworks/1.2/utils/src/PreparedModel.cpp b/neuralnetworks/1.2/utils/src/PreparedModel.cpp
index dad9a7e..b422ced 100644
--- a/neuralnetworks/1.2/utils/src/PreparedModel.cpp
+++ b/neuralnetworks/1.2/utils/src/PreparedModel.cpp
@@ -37,6 +37,9 @@
 #include <utility>
 #include <vector>
 
+// See hardware/interfaces/neuralnetworks/utils/README.md for more information on HIDL interface
+// lifetimes across processes and for protecting asynchronous calls across HIDL.
+
 namespace android::hardware::neuralnetworks::V1_2::utils {
 namespace {
 
@@ -106,7 +109,7 @@
 nn::ExecutionResult<std::pair<std::vector<nn::OutputShape>, nn::Timing>> PreparedModel::execute(
         const nn::Request& request, nn::MeasureTiming measure,
         const nn::OptionalTimePoint& /*deadline*/,
-        const nn::OptionalTimeoutDuration& /*loopTimeoutDuration*/) const {
+        const nn::OptionalDuration& /*loopTimeoutDuration*/) const {
     // Ensure that request is ready for IPC.
     std::optional<nn::Request> maybeRequestInShared;
     const nn::Request& requestInShared = NN_TRY(hal::utils::makeExecutionFailure(
@@ -140,11 +143,12 @@
 }
 
 nn::GeneralResult<std::pair<nn::SyncFence, nn::ExecuteFencedInfoCallback>>
-PreparedModel::executeFenced(
-        const nn::Request& /*request*/, const std::vector<nn::SyncFence>& /*waitFor*/,
-        nn::MeasureTiming /*measure*/, const nn::OptionalTimePoint& /*deadline*/,
-        const nn::OptionalTimeoutDuration& /*loopTimeoutDuration*/,
-        const nn::OptionalTimeoutDuration& /*timeoutDurationAfterFence*/) const {
+PreparedModel::executeFenced(const nn::Request& /*request*/,
+                             const std::vector<nn::SyncFence>& /*waitFor*/,
+                             nn::MeasureTiming /*measure*/,
+                             const nn::OptionalTimePoint& /*deadline*/,
+                             const nn::OptionalDuration& /*loopTimeoutDuration*/,
+                             const nn::OptionalDuration& /*timeoutDurationAfterFence*/) const {
     return NN_ERROR(nn::ErrorStatus::GENERAL_FAILURE)
            << "IPreparedModel::executeFenced is not supported on 1.2 HAL service";
 }
diff --git a/neuralnetworks/1.3/utils/include/nnapi/hal/1.3/Buffer.h b/neuralnetworks/1.3/utils/include/nnapi/hal/1.3/Buffer.h
index 637179d..fda79c8 100644
--- a/neuralnetworks/1.3/utils/include/nnapi/hal/1.3/Buffer.h
+++ b/neuralnetworks/1.3/utils/include/nnapi/hal/1.3/Buffer.h
@@ -24,8 +24,12 @@
 #include <nnapi/Types.h>
 #include <memory>
 
+// See hardware/interfaces/neuralnetworks/utils/README.md for more information on HIDL interface
+// lifetimes across processes.
+
 namespace android::hardware::neuralnetworks::V1_3::utils {
 
+// Class that adapts V1_3::IBuffer to nn::IBuffer.
 class Buffer final : public nn::IBuffer {
     struct PrivateConstructorTag {};
 
diff --git a/neuralnetworks/1.3/utils/include/nnapi/hal/1.3/Callbacks.h b/neuralnetworks/1.3/utils/include/nnapi/hal/1.3/Callbacks.h
index d46b111..cb2a56a 100644
--- a/neuralnetworks/1.3/utils/include/nnapi/hal/1.3/Callbacks.h
+++ b/neuralnetworks/1.3/utils/include/nnapi/hal/1.3/Callbacks.h
@@ -34,6 +34,9 @@
 #include <nnapi/hal/ProtectCallback.h>
 #include <nnapi/hal/TransferValue.h>
 
+// See hardware/interfaces/neuralnetworks/utils/README.md for more information on HIDL interface
+// lifetimes across processes and for protecting asynchronous calls across HIDL.
+
 namespace android::hardware::neuralnetworks::V1_3::utils {
 
 class PreparedModelCallback final : public IPreparedModelCallback,
diff --git a/neuralnetworks/1.3/utils/include/nnapi/hal/1.3/Conversions.h b/neuralnetworks/1.3/utils/include/nnapi/hal/1.3/Conversions.h
index 9653a05..477bb7b 100644
--- a/neuralnetworks/1.3/utils/include/nnapi/hal/1.3/Conversions.h
+++ b/neuralnetworks/1.3/utils/include/nnapi/hal/1.3/Conversions.h
@@ -44,7 +44,7 @@
         const hal::V1_3::Request::MemoryPool& memoryPool);
 GeneralResult<OptionalTimePoint> unvalidatedConvert(
         const hal::V1_3::OptionalTimePoint& optionalTimePoint);
-GeneralResult<OptionalTimeoutDuration> unvalidatedConvert(
+GeneralResult<OptionalDuration> unvalidatedConvert(
         const hal::V1_3::OptionalTimeoutDuration& optionalTimeoutDuration);
 GeneralResult<ErrorStatus> unvalidatedConvert(const hal::V1_3::ErrorStatus& errorStatus);
 
@@ -54,7 +54,7 @@
 GeneralResult<BufferDesc> convert(const hal::V1_3::BufferDesc& bufferDesc);
 GeneralResult<Request> convert(const hal::V1_3::Request& request);
 GeneralResult<OptionalTimePoint> convert(const hal::V1_3::OptionalTimePoint& optionalTimePoint);
-GeneralResult<OptionalTimeoutDuration> convert(
+GeneralResult<OptionalDuration> convert(
         const hal::V1_3::OptionalTimeoutDuration& optionalTimeoutDuration);
 GeneralResult<ErrorStatus> convert(const hal::V1_3::ErrorStatus& errorStatus);
 
@@ -86,7 +86,7 @@
 nn::GeneralResult<OptionalTimePoint> unvalidatedConvert(
         const nn::OptionalTimePoint& optionalTimePoint);
 nn::GeneralResult<OptionalTimeoutDuration> unvalidatedConvert(
-        const nn::OptionalTimeoutDuration& optionalTimeoutDuration);
+        const nn::OptionalDuration& optionalTimeoutDuration);
 nn::GeneralResult<ErrorStatus> unvalidatedConvert(const nn::ErrorStatus& errorStatus);
 
 nn::GeneralResult<Priority> convert(const nn::Priority& priority);
@@ -96,7 +96,7 @@
 nn::GeneralResult<Request> convert(const nn::Request& request);
 nn::GeneralResult<OptionalTimePoint> convert(const nn::OptionalTimePoint& optionalTimePoint);
 nn::GeneralResult<OptionalTimeoutDuration> convert(
-        const nn::OptionalTimeoutDuration& optionalTimeoutDuration);
+        const nn::OptionalDuration& optionalTimeoutDuration);
 nn::GeneralResult<ErrorStatus> convert(const nn::ErrorStatus& errorStatus);
 
 nn::GeneralResult<hidl_handle> convert(const nn::SharedHandle& handle);
diff --git a/neuralnetworks/1.3/utils/include/nnapi/hal/1.3/Device.h b/neuralnetworks/1.3/utils/include/nnapi/hal/1.3/Device.h
index 0f5234b..84f606a 100644
--- a/neuralnetworks/1.3/utils/include/nnapi/hal/1.3/Device.h
+++ b/neuralnetworks/1.3/utils/include/nnapi/hal/1.3/Device.h
@@ -32,8 +32,12 @@
 #include <string>
 #include <vector>
 
+// See hardware/interfaces/neuralnetworks/utils/README.md for more information on HIDL interface
+// lifetimes across processes and for protecting asynchronous calls across HIDL.
+
 namespace android::hardware::neuralnetworks::V1_3::utils {
 
+// Class that adapts V1_3::IDevice to nn::IDevice.
 class Device final : public nn::IDevice {
     struct PrivateConstructorTag {};
 
diff --git a/neuralnetworks/1.3/utils/include/nnapi/hal/1.3/PreparedModel.h b/neuralnetworks/1.3/utils/include/nnapi/hal/1.3/PreparedModel.h
index e0d69dd..c4ba483 100644
--- a/neuralnetworks/1.3/utils/include/nnapi/hal/1.3/PreparedModel.h
+++ b/neuralnetworks/1.3/utils/include/nnapi/hal/1.3/PreparedModel.h
@@ -29,8 +29,12 @@
 #include <utility>
 #include <vector>
 
+// See hardware/interfaces/neuralnetworks/utils/README.md for more information on HIDL interface
+// lifetimes across processes and for protecting asynchronous calls across HIDL.
+
 namespace android::hardware::neuralnetworks::V1_3::utils {
 
+// Class that adapts V1_3::IPreparedModel to nn::IPreparedModel.
 class PreparedModel final : public nn::IPreparedModel {
     struct PrivateConstructorTag {};
 
@@ -44,13 +48,13 @@
     nn::ExecutionResult<std::pair<std::vector<nn::OutputShape>, nn::Timing>> execute(
             const nn::Request& request, nn::MeasureTiming measure,
             const nn::OptionalTimePoint& deadline,
-            const nn::OptionalTimeoutDuration& loopTimeoutDuration) const override;
+            const nn::OptionalDuration& loopTimeoutDuration) const override;
 
     nn::GeneralResult<std::pair<nn::SyncFence, nn::ExecuteFencedInfoCallback>> executeFenced(
             const nn::Request& request, const std::vector<nn::SyncFence>& waitFor,
             nn::MeasureTiming measure, const nn::OptionalTimePoint& deadline,
-            const nn::OptionalTimeoutDuration& loopTimeoutDuration,
-            const nn::OptionalTimeoutDuration& timeoutDurationAfterFence) const override;
+            const nn::OptionalDuration& loopTimeoutDuration,
+            const nn::OptionalDuration& timeoutDurationAfterFence) const override;
 
     std::any getUnderlyingResource() const override;
 
diff --git a/neuralnetworks/1.3/utils/src/Buffer.cpp b/neuralnetworks/1.3/utils/src/Buffer.cpp
index ffdeccd..4ef54a2 100644
--- a/neuralnetworks/1.3/utils/src/Buffer.cpp
+++ b/neuralnetworks/1.3/utils/src/Buffer.cpp
@@ -33,6 +33,9 @@
 #include <memory>
 #include <utility>
 
+// See hardware/interfaces/neuralnetworks/utils/README.md for more information on HIDL interface
+// lifetimes across processes.
+
 namespace android::hardware::neuralnetworks::V1_3::utils {
 
 nn::GeneralResult<std::shared_ptr<const Buffer>> Buffer::create(
diff --git a/neuralnetworks/1.3/utils/src/Callbacks.cpp b/neuralnetworks/1.3/utils/src/Callbacks.cpp
index e3c6074..17c20fb 100644
--- a/neuralnetworks/1.3/utils/src/Callbacks.cpp
+++ b/neuralnetworks/1.3/utils/src/Callbacks.cpp
@@ -39,6 +39,9 @@
 
 #include <utility>
 
+// See hardware/interfaces/neuralnetworks/utils/README.md for more information on HIDL interface
+// lifetimes across processes and for protecting asynchronous calls across HIDL.
+
 namespace android::hardware::neuralnetworks::V1_3::utils {
 namespace {
 
diff --git a/neuralnetworks/1.3/utils/src/Conversions.cpp b/neuralnetworks/1.3/utils/src/Conversions.cpp
index 949dd0d..c89a69f 100644
--- a/neuralnetworks/1.3/utils/src/Conversions.cpp
+++ b/neuralnetworks/1.3/utils/src/Conversions.cpp
@@ -272,47 +272,26 @@
 
 GeneralResult<OptionalTimePoint> unvalidatedConvert(
         const hal::V1_3::OptionalTimePoint& optionalTimePoint) {
-    constexpr auto kTimePointMaxCount = TimePoint::max().time_since_epoch().count();
-    const auto makeTimePoint = [](uint64_t count) -> GeneralResult<OptionalTimePoint> {
-        if (count > kTimePointMaxCount) {
-            return NN_ERROR(nn::ErrorStatus::GENERAL_FAILURE)
-                   << "Unable to unvalidatedConvert OptionalTimePoint because the count exceeds "
-                      "the max";
-        }
-        const auto nanoseconds = std::chrono::nanoseconds{count};
-        return TimePoint{nanoseconds};
-    };
-
     using Discriminator = hal::V1_3::OptionalTimePoint::hidl_discriminator;
     switch (optionalTimePoint.getDiscriminator()) {
         case Discriminator::none:
-            return std::nullopt;
+            return {};
         case Discriminator::nanosecondsSinceEpoch:
-            return makeTimePoint(optionalTimePoint.nanosecondsSinceEpoch());
+            return TimePoint{Duration{optionalTimePoint.nanosecondsSinceEpoch()}};
     }
     return NN_ERROR(nn::ErrorStatus::GENERAL_FAILURE)
            << "Invalid OptionalTimePoint discriminator "
            << underlyingType(optionalTimePoint.getDiscriminator());
 }
 
-GeneralResult<OptionalTimeoutDuration> unvalidatedConvert(
+GeneralResult<OptionalDuration> unvalidatedConvert(
         const hal::V1_3::OptionalTimeoutDuration& optionalTimeoutDuration) {
-    constexpr auto kTimeoutDurationMaxCount = TimeoutDuration::max().count();
-    const auto makeTimeoutDuration = [](uint64_t count) -> GeneralResult<OptionalTimeoutDuration> {
-        if (count > kTimeoutDurationMaxCount) {
-            return NN_ERROR(nn::ErrorStatus::GENERAL_FAILURE)
-                   << "Unable to unvalidatedConvert OptionalTimeoutDuration because the count "
-                      "exceeds the max";
-        }
-        return TimeoutDuration{count};
-    };
-
     using Discriminator = hal::V1_3::OptionalTimeoutDuration::hidl_discriminator;
     switch (optionalTimeoutDuration.getDiscriminator()) {
         case Discriminator::none:
-            return std::nullopt;
+            return {};
         case Discriminator::nanoseconds:
-            return makeTimeoutDuration(optionalTimeoutDuration.nanoseconds());
+            return Duration(optionalTimeoutDuration.nanoseconds());
     }
     return NN_ERROR(nn::ErrorStatus::GENERAL_FAILURE)
            << "Invalid OptionalTimeoutDuration discriminator "
@@ -360,7 +339,7 @@
     return validatedConvert(optionalTimePoint);
 }
 
-GeneralResult<OptionalTimeoutDuration> convert(
+GeneralResult<OptionalDuration> convert(
         const hal::V1_3::OptionalTimeoutDuration& optionalTimeoutDuration) {
     return validatedConvert(optionalTimeoutDuration);
 }
@@ -629,27 +608,16 @@
     OptionalTimePoint ret;
     if (optionalTimePoint.has_value()) {
         const auto count = optionalTimePoint.value().time_since_epoch().count();
-        if (count < 0) {
-            return NN_ERROR(nn::ErrorStatus::GENERAL_FAILURE)
-                   << "Unable to unvalidatedConvert OptionalTimePoint because time since epoch "
-                      "count is "
-                      "negative";
-        }
         ret.nanosecondsSinceEpoch(count);
     }
     return ret;
 }
 
 nn::GeneralResult<OptionalTimeoutDuration> unvalidatedConvert(
-        const nn::OptionalTimeoutDuration& optionalTimeoutDuration) {
+        const nn::OptionalDuration& optionalTimeoutDuration) {
     OptionalTimeoutDuration ret;
     if (optionalTimeoutDuration.has_value()) {
         const auto count = optionalTimeoutDuration.value().count();
-        if (count < 0) {
-            return NN_ERROR(nn::ErrorStatus::GENERAL_FAILURE)
-                   << "Unable to unvalidatedConvert OptionalTimeoutDuration because count is "
-                      "negative";
-        }
         ret.nanoseconds(count);
     }
     return ret;
@@ -697,7 +665,7 @@
 }
 
 nn::GeneralResult<OptionalTimeoutDuration> convert(
-        const nn::OptionalTimeoutDuration& optionalTimeoutDuration) {
+        const nn::OptionalDuration& optionalTimeoutDuration) {
     return validatedConvert(optionalTimeoutDuration);
 }
 
diff --git a/neuralnetworks/1.3/utils/src/Device.cpp b/neuralnetworks/1.3/utils/src/Device.cpp
index 82837ba..6056498 100644
--- a/neuralnetworks/1.3/utils/src/Device.cpp
+++ b/neuralnetworks/1.3/utils/src/Device.cpp
@@ -47,6 +47,9 @@
 #include <string>
 #include <vector>
 
+// See hardware/interfaces/neuralnetworks/utils/README.md for more information on HIDL interface
+// lifetimes across processes and for protecting asynchronous calls across HIDL.
+
 namespace android::hardware::neuralnetworks::V1_3::utils {
 namespace {
 
diff --git a/neuralnetworks/1.3/utils/src/PreparedModel.cpp b/neuralnetworks/1.3/utils/src/PreparedModel.cpp
index 49b9b0b..0bae95d 100644
--- a/neuralnetworks/1.3/utils/src/PreparedModel.cpp
+++ b/neuralnetworks/1.3/utils/src/PreparedModel.cpp
@@ -39,6 +39,9 @@
 #include <utility>
 #include <vector>
 
+// See hardware/interfaces/neuralnetworks/utils/README.md for more information on HIDL interface
+// lifetimes across processes and for protecting asynchronous calls across HIDL.
+
 namespace android::hardware::neuralnetworks::V1_3::utils {
 namespace {
 
@@ -159,7 +162,7 @@
 nn::ExecutionResult<std::pair<std::vector<nn::OutputShape>, nn::Timing>> PreparedModel::execute(
         const nn::Request& request, nn::MeasureTiming measure,
         const nn::OptionalTimePoint& deadline,
-        const nn::OptionalTimeoutDuration& loopTimeoutDuration) const {
+        const nn::OptionalDuration& loopTimeoutDuration) const {
     // Ensure that request is ready for IPC.
     std::optional<nn::Request> maybeRequestInShared;
     const nn::Request& requestInShared = NN_TRY(hal::utils::makeExecutionFailure(
@@ -200,8 +203,8 @@
 nn::GeneralResult<std::pair<nn::SyncFence, nn::ExecuteFencedInfoCallback>>
 PreparedModel::executeFenced(const nn::Request& request, const std::vector<nn::SyncFence>& waitFor,
                              nn::MeasureTiming measure, const nn::OptionalTimePoint& deadline,
-                             const nn::OptionalTimeoutDuration& loopTimeoutDuration,
-                             const nn::OptionalTimeoutDuration& timeoutDurationAfterFence) const {
+                             const nn::OptionalDuration& loopTimeoutDuration,
+                             const nn::OptionalDuration& timeoutDurationAfterFence) const {
     // Ensure that request is ready for IPC.
     std::optional<nn::Request> maybeRequestInShared;
     const nn::Request& requestInShared =
diff --git a/neuralnetworks/utils/README.md b/neuralnetworks/utils/README.md
index 0dee103..45ca0b4 100644
--- a/neuralnetworks/utils/README.md
+++ b/neuralnetworks/utils/README.md
@@ -1,11 +1,11 @@
 # NNAPI Conversions
 
 `convert` fails if either the source type or the destination type is invalid, and it yields a valid
-object if the conversion succeeds. For example, let's say that an enumeration in the current
-version has fewer possible values than the "same" canonical enumeration, such as `OperationType`.
-The new value of `HARD_SWISH` (introduced in Android R / NN HAL 1.3) does not map to any valid
-existing value in `OperationType`, but an older value of `ADD` (introduced in Android OC-MR1 / NN
-HAL 1.0) is valid. This can be seen in the following model conversions:
+object if the conversion succeeds. For example, let's say that an enumeration in the current version
+has fewer possible values than the "same" canonical enumeration, such as `OperationType`. The new
+value of `HARD_SWISH` (introduced in Android R / NN HAL 1.3) does not map to any valid existing
+value in `OperationType`, but an older value of `ADD` (introduced in Android OC-MR1 / NN HAL 1.0) is
+valid. This can be seen in the following model conversions:
 
 ```cpp
 // Unsuccessful conversion
@@ -48,3 +48,50 @@
 `unvalidatedConvert` functions operate on types that are either used in a HIDL method call directly
 (i.e., not as a nested class) or used in a subsequent version of the NN HAL. Prefer using `convert`
 over `unvalidatedConvert`.
+
+# HIDL Interface Lifetimes across Processes
+
+Some notes about HIDL interface objects and lifetimes across processes:
+
+All HIDL interface objects inherit from `IBase`, which itself inherits from `::android::RefBase`. As
+such, all HIDL interface objects are reference counted and must be owned through `::android::sp` (or
+referenced through `::android::wp`). Allocating `RefBase` objects on the stack will log errors and
+may result in crashes, and deleting a `RefBase` object through another means (e.g., "delete",
+"free", or RAII-cleanup through `std::unique_ptr` or some equivalent) will result in double-free
+and/or use-after-free undefined behavior.
+
+HIDL/Binder manages the reference count of HIDL interface objects automatically across processes. If
+a process that references (but did not create) the HIDL interface object dies, HIDL/Binder ensures
+any reference count it held is properly released. (Caveat: it might be possible that HIDL/Binder
+behave strangely with `::android::wp` references.)
+
+If the process which created the HIDL interface object dies, any call on this object from another
+process will result in a HIDL transport error with the code `DEAD_OBJECT`.
+
+# Protecting Asynchronous Calls across HIDL
+
+Some notes about asynchronous calls across HIDL:
+
+For synchronous calls across HIDL, if an error occurs after the function was called but before it
+returns, HIDL will return a transport error. For example, if the message cannot be delivered to the
+server process or if the server process dies before returning a result, HIDL will return from the
+function with the appropriate transport error in the `Return<>` object, which can be queried with
+`Return<>::isOk()`, `Return<>::isDeadObject()`, `Return<>::description()`, etc.
+
+However, HIDL offers no such error management in the case of asynchronous calls. By default, if the
+client launches an asynchronous task and the server fails to return a result through the callback,
+the client will be left waiting indefinitely for a result it will never receive.
+
+In the NNAPI, `IDevice::prepareModel*` and `IPreparedModel::execute*` (but not
+`IPreparedModel::executeSynchronously*`) are asynchronous calls across HIDL. Specifically, these
+asynchronous functions are called with a HIDL interface callback object (`IPrepareModelCallback` for
+`IDevice::prepareModel*` and `IExecutionCallback` for `IPreparedModel::execute*`) and are expected
+to quickly return, and the results are returned at a later time through these callback objects.
+
+To protect against the case when the server dies after the asynchronous task was called successfully
+but before the results could be returned, HIDL provides an object called a "`hidl_death_recipient`,"
+which can be used to detect when an interface object (and more generally, the server process) has
+died. nnapi/hal/ProtectCallback.h's `DeathHandler` uses `hidl_death_recipient`s to detect when the
+driver process has died, and `DeathHandler` will unblock any thread waiting on the results of an
+`IProtectedCallback` callback object that may otherwise not be signaled. In order for this to work,
+the `IProtectedCallback` object must have been registered via `DeathHandler::protectCallback()`.
diff --git a/neuralnetworks/utils/common/include/nnapi/hal/InvalidPreparedModel.h b/neuralnetworks/utils/common/include/nnapi/hal/InvalidPreparedModel.h
index 4b32b4e..985cddb 100644
--- a/neuralnetworks/utils/common/include/nnapi/hal/InvalidPreparedModel.h
+++ b/neuralnetworks/utils/common/include/nnapi/hal/InvalidPreparedModel.h
@@ -32,13 +32,13 @@
     nn::ExecutionResult<std::pair<std::vector<nn::OutputShape>, nn::Timing>> execute(
             const nn::Request& request, nn::MeasureTiming measure,
             const nn::OptionalTimePoint& deadline,
-            const nn::OptionalTimeoutDuration& loopTimeoutDuration) const override;
+            const nn::OptionalDuration& loopTimeoutDuration) const override;
 
     nn::GeneralResult<std::pair<nn::SyncFence, nn::ExecuteFencedInfoCallback>> executeFenced(
             const nn::Request& request, const std::vector<nn::SyncFence>& waitFor,
             nn::MeasureTiming measure, const nn::OptionalTimePoint& deadline,
-            const nn::OptionalTimeoutDuration& loopTimeoutDuration,
-            const nn::OptionalTimeoutDuration& timeoutDurationAfterFence) const override;
+            const nn::OptionalDuration& loopTimeoutDuration,
+            const nn::OptionalDuration& timeoutDurationAfterFence) const override;
 
     std::any getUnderlyingResource() const override;
 };
diff --git a/neuralnetworks/utils/common/include/nnapi/hal/ProtectCallback.h b/neuralnetworks/utils/common/include/nnapi/hal/ProtectCallback.h
index 85bd613..c921885 100644
--- a/neuralnetworks/utils/common/include/nnapi/hal/ProtectCallback.h
+++ b/neuralnetworks/utils/common/include/nnapi/hal/ProtectCallback.h
@@ -28,6 +28,9 @@
 #include <mutex>
 #include <vector>
 
+// See hardware/interfaces/neuralnetworks/utils/README.md for more information on HIDL interface
+// lifetimes across processes and for protecting asynchronous calls across HIDL.
+
 namespace android::hardware::neuralnetworks::utils {
 
 class IProtectedCallback {
diff --git a/neuralnetworks/utils/common/include/nnapi/hal/ResilientPreparedModel.h b/neuralnetworks/utils/common/include/nnapi/hal/ResilientPreparedModel.h
index c2940d1..d86c88b 100644
--- a/neuralnetworks/utils/common/include/nnapi/hal/ResilientPreparedModel.h
+++ b/neuralnetworks/utils/common/include/nnapi/hal/ResilientPreparedModel.h
@@ -49,13 +49,13 @@
     nn::ExecutionResult<std::pair<std::vector<nn::OutputShape>, nn::Timing>> execute(
             const nn::Request& request, nn::MeasureTiming measure,
             const nn::OptionalTimePoint& deadline,
-            const nn::OptionalTimeoutDuration& loopTimeoutDuration) const override;
+            const nn::OptionalDuration& loopTimeoutDuration) const override;
 
     nn::GeneralResult<std::pair<nn::SyncFence, nn::ExecuteFencedInfoCallback>> executeFenced(
             const nn::Request& request, const std::vector<nn::SyncFence>& waitFor,
             nn::MeasureTiming measure, const nn::OptionalTimePoint& deadline,
-            const nn::OptionalTimeoutDuration& loopTimeoutDuration,
-            const nn::OptionalTimeoutDuration& timeoutDurationAfterFence) const override;
+            const nn::OptionalDuration& loopTimeoutDuration,
+            const nn::OptionalDuration& timeoutDurationAfterFence) const override;
 
     std::any getUnderlyingResource() const override;
 
diff --git a/neuralnetworks/utils/common/src/InvalidPreparedModel.cpp b/neuralnetworks/utils/common/src/InvalidPreparedModel.cpp
index 9ae7a63..a46f4ac 100644
--- a/neuralnetworks/utils/common/src/InvalidPreparedModel.cpp
+++ b/neuralnetworks/utils/common/src/InvalidPreparedModel.cpp
@@ -29,7 +29,7 @@
 nn::ExecutionResult<std::pair<std::vector<nn::OutputShape>, nn::Timing>>
 InvalidPreparedModel::execute(const nn::Request& /*request*/, nn::MeasureTiming /*measure*/,
                               const nn::OptionalTimePoint& /*deadline*/,
-                              const nn::OptionalTimeoutDuration& /*loopTimeoutDuration*/) const {
+                              const nn::OptionalDuration& /*loopTimeoutDuration*/) const {
     return NN_ERROR() << "InvalidPreparedModel";
 }
 
@@ -37,8 +37,8 @@
 InvalidPreparedModel::executeFenced(
         const nn::Request& /*request*/, const std::vector<nn::SyncFence>& /*waitFor*/,
         nn::MeasureTiming /*measure*/, const nn::OptionalTimePoint& /*deadline*/,
-        const nn::OptionalTimeoutDuration& /*loopTimeoutDuration*/,
-        const nn::OptionalTimeoutDuration& /*timeoutDurationAfterFence*/) const {
+        const nn::OptionalDuration& /*loopTimeoutDuration*/,
+        const nn::OptionalDuration& /*timeoutDurationAfterFence*/) const {
     return NN_ERROR() << "InvalidPreparedModel";
 }
 
diff --git a/neuralnetworks/utils/common/src/ResilientPreparedModel.cpp b/neuralnetworks/utils/common/src/ResilientPreparedModel.cpp
index 1c9ecba..012a1de 100644
--- a/neuralnetworks/utils/common/src/ResilientPreparedModel.cpp
+++ b/neuralnetworks/utils/common/src/ResilientPreparedModel.cpp
@@ -64,16 +64,17 @@
 nn::ExecutionResult<std::pair<std::vector<nn::OutputShape>, nn::Timing>>
 ResilientPreparedModel::execute(const nn::Request& request, nn::MeasureTiming measure,
                                 const nn::OptionalTimePoint& deadline,
-                                const nn::OptionalTimeoutDuration& loopTimeoutDuration) const {
+                                const nn::OptionalDuration& loopTimeoutDuration) const {
     return getPreparedModel()->execute(request, measure, deadline, loopTimeoutDuration);
 }
 
 nn::GeneralResult<std::pair<nn::SyncFence, nn::ExecuteFencedInfoCallback>>
-ResilientPreparedModel::executeFenced(
-        const nn::Request& request, const std::vector<nn::SyncFence>& waitFor,
-        nn::MeasureTiming measure, const nn::OptionalTimePoint& deadline,
-        const nn::OptionalTimeoutDuration& loopTimeoutDuration,
-        const nn::OptionalTimeoutDuration& timeoutDurationAfterFence) const {
+ResilientPreparedModel::executeFenced(const nn::Request& request,
+                                      const std::vector<nn::SyncFence>& waitFor,
+                                      nn::MeasureTiming measure,
+                                      const nn::OptionalTimePoint& deadline,
+                                      const nn::OptionalDuration& loopTimeoutDuration,
+                                      const nn::OptionalDuration& timeoutDurationAfterFence) const {
     return getPreparedModel()->executeFenced(request, waitFor, measure, deadline,
                                              loopTimeoutDuration, timeoutDurationAfterFence);
 }
diff --git a/nfc/1.0/vts/functional/AndroidTest.xml b/nfc/1.0/vts/functional/AndroidTest.xml
index 364672b..76aca48 100644
--- a/nfc/1.0/vts/functional/AndroidTest.xml
+++ b/nfc/1.0/vts/functional/AndroidTest.xml
@@ -28,6 +28,6 @@
     <test class="com.android.tradefed.testtype.GTest" >
         <option name="native-test-device-path" value="/data/local/tmp" />
         <option name="module-name" value="VtsHalNfcV1_0TargetTest" />
-        <option name="native-test-timeout" value="180000"/>
+        <option name="native-test-timeout" value="600000"/>
     </test>
 </configuration>
diff --git a/radio/1.6/IRadio.hal b/radio/1.6/IRadio.hal
index 2c8ac5e..3dc80b9 100644
--- a/radio/1.6/IRadio.hal
+++ b/radio/1.6/IRadio.hal
@@ -327,12 +327,26 @@
      * @param serial Serial number of request.
      * @param networkTypeBitmap a 32-bit bearer bitmap of RadioAccessFamily
      *
-     * Response callbask is IRadioResponse.setNetworkTypeBitmapResponse()
+     * Response callback is IRadioResponse.setNetworkTypeBitmapResponse()
      */
     oneway setAllowedNetworkTypeBitmap(
             uint32_t serial, bitfield<RadioAccessFamily> networkTypeBitmap);
 
     /**
+     * Requests bitmap representing the currently allowed network types.
+     *
+     * Requests the bitmap set by the corresponding method
+     * setAllowedNetworkTypeBitmap, which sets a strict set of RATs for the
+     * radio to use. Differs from getPreferredNetworkType and getPreferredNetworkTypeBitmap
+     * in that those request *preferences*.
+     *
+     * @param serial Serial number of request.
+     *
+     * Response callback is IRadioResponse.getNetworkTypeBitmapResponse()
+     */
+    oneway getAllowedNetworkTypeBitmap(uint32_t serial);
+
+    /**
      * Control data throttling at modem.
      *   - DataThrottlingAction:NO_DATA_THROTTLING should clear any existing
      *     data throttling within the requested completion window.
@@ -406,4 +420,13 @@
      * Response function is IRadioResponse.getDataRegistrationStateResponse_1_6()
      */
     oneway getDataRegistrationState_1_6(int32_t serial);
+
+    /**
+     * Requests current call list
+     *
+     * @param serial Serial number of request.
+     *
+     * Response function is IRadioResponse.getCurrentCallsResponse_1_6()
+     */
+    oneway getCurrentCalls_1_6(int32_t serial);
 };
diff --git a/radio/1.6/IRadioResponse.hal b/radio/1.6/IRadioResponse.hal
index 3b2061f..6ac86c3 100644
--- a/radio/1.6/IRadioResponse.hal
+++ b/radio/1.6/IRadioResponse.hal
@@ -17,7 +17,9 @@
 package android.hardware.radio@1.6;
 
 import @1.0::SendSmsResult;
+import @1.4::RadioAccessFamily;
 import @1.5::IRadioResponse;
+import @1.6::Call;
 import @1.6::CellInfo;
 import @1.6::RegStateResult;
 import @1.6::RadioResponseInfo;
@@ -310,6 +312,23 @@
     oneway setAllowedNetworkTypeBitmapResponse(RadioResponseInfo info);
 
     /**
+     * Callback of IRadio.getAllowedNetworkTypeBitmap(int, bitfield<RadioAccessFamily>)
+     *
+     * Valid errors returned:
+     *   RadioError:NONE
+     *   RadioError:RADIO_NOT_AVAILABLE
+     *   RadioError:OPERATION_NOT_ALLOWED
+     *   RadioError:MODE_NOT_SUPPORTED
+     *   RadioError:INTERNAL_ERR
+     *   RadioError:INVALID_ARGUMENTS
+     *   RadioError:MODEM_ERR
+     *   RadioError:REQUEST_NOT_SUPPORTED
+     *   RadioError:NO_RESOURCES
+     */
+    oneway getAllowedNetworkTypeBitmapResponse(
+            RadioResponseInfo info, bitfield<RadioAccessFamily> networkTypeBitmap);
+
+    /**
      * @param info Response info struct containing response type, serial no. and error
      *
      *  Valid errors returned:
@@ -383,4 +402,16 @@
      */
     oneway getDataRegistrationStateResponse_1_6(RadioResponseInfo info,
             RegStateResult dataRegResponse);
+
+    /**
+     * @param calls Current call list
+     *   RadioError:NO_MEMORY
+     *   RadioError:INTERNAL_ERR
+     *   RadioError:SYSTEM_ERR
+     *   RadioError:INVALID_ARGUMENTS
+     *   RadioError:REQUEST_NOT_SUPPORTED
+     *   RadioError:NO_RESOURCES
+     *   RadioError:CANCELLED
+     */
+    oneway getCurrentCallsResponse_1_6(RadioResponseInfo info, vec<Call> calls);
 };
diff --git a/radio/1.6/types.hal b/radio/1.6/types.hal
index 20dc612..f4dc0bd 100644
--- a/radio/1.6/types.hal
+++ b/radio/1.6/types.hal
@@ -24,6 +24,7 @@
 import @1.0::RadioResponseType;
 import @1.0::RegState;
 import @1.1::ScanStatus;
+import @1.2::Call;
 import @1.2::CellInfoCdma;
 import @1.2::CellConnectionStatus;
 import @1.2::TdscdmaSignalStrength;
@@ -723,3 +724,12 @@
         } ngranInfo;
     } accessTechnologySpecificInfo;
 };
+
+struct Call {
+    @1.2::Call base;
+    /**
+     * Forwarded number. It can set only one forwarded number based on 3GPP rule of the CS.
+     * Reference: 3GPP TS 24.008 section 10.5.4.21b
+     */
+    string forwardedNumber;
+};
diff --git a/radio/1.6/vts/functional/radio_hidl_hal_api.cpp b/radio/1.6/vts/functional/radio_hidl_hal_api.cpp
index 75772cd..47babed 100644
--- a/radio/1.6/vts/functional/radio_hidl_hal_api.cpp
+++ b/radio/1.6/vts/functional/radio_hidl_hal_api.cpp
@@ -406,3 +406,15 @@
         EXPECT_EQ(CardState::PRESENT, cardStatus.base.base.base.cardState);
     }
 }
+
+/*
+ * Test IRadio.getCurrentCalls_1_6() for the response returned.
+ */
+TEST_P(RadioHidlTest_v1_6, getCurrentCalls_1_6) {
+    serial = GetRandomSerialNumber();
+    radio_v1_6->getCurrentCalls_1_6(serial);
+    EXPECT_EQ(std::cv_status::no_timeout, wait());
+    EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_6->rspInfo.type);
+    EXPECT_EQ(serial, radioRsp_v1_6->rspInfo.serial);
+    EXPECT_EQ(::android::hardware::radio::V1_6::RadioError::NONE, radioRsp_v1_6->rspInfo.error);
+}
diff --git a/radio/1.6/vts/functional/radio_hidl_hal_utils_v1_6.h b/radio/1.6/vts/functional/radio_hidl_hal_utils_v1_6.h
index 111fcd1..fbcd7a9 100644
--- a/radio/1.6/vts/functional/radio_hidl_hal_utils_v1_6.h
+++ b/radio/1.6/vts/functional/radio_hidl_hal_utils_v1_6.h
@@ -793,6 +793,12 @@
     Return<void> setAllowedNetworkTypeBitmapResponse(
             const ::android::hardware::radio::V1_6::RadioResponseInfo& info);
 
+    Return<void> getAllowedNetworkTypeBitmapResponse(
+            const ::android::hardware::radio::V1_6::RadioResponseInfo& info,
+            const ::android::hardware::hidl_bitfield<
+                    ::android::hardware::radio::V1_4::RadioAccessFamily>
+                    networkTypeBitmap);
+
     Return<void> setDataThrottlingResponse(
             const ::android::hardware::radio::V1_6::RadioResponseInfo& info);
 
@@ -815,6 +821,10 @@
     Return<void> getDataRegistrationStateResponse_1_6(
             const ::android::hardware::radio::V1_6::RadioResponseInfo& info,
             const ::android::hardware::radio::V1_6::RegStateResult& regResponse);
+
+    Return<void> getCurrentCallsResponse_1_6(
+            const ::android::hardware::radio::V1_6::RadioResponseInfo& info,
+            const ::android::hardware::hidl_vec<::android::hardware::radio::V1_6::Call>& calls);
 };
 
 /* Callback class for radio indication */
diff --git a/radio/1.6/vts/functional/radio_response.cpp b/radio/1.6/vts/functional/radio_response.cpp
index 68d1f20..7c5cf6d 100644
--- a/radio/1.6/vts/functional/radio_response.cpp
+++ b/radio/1.6/vts/functional/radio_response.cpp
@@ -1157,6 +1157,14 @@
     return Void();
 }
 
+Return<void> RadioResponse_v1_6::getAllowedNetworkTypeBitmapResponse(
+        const ::android::hardware::radio::V1_6::RadioResponseInfo& /*info*/,
+        const ::android::hardware::hidl_bitfield<
+                ::android::hardware::radio::V1_4::RadioAccessFamily>
+        /*networkTypeBitmap*/) {
+    return Void();
+}
+
 Return<void> RadioResponse_v1_6::setDataThrottlingResponse(
         const ::android::hardware::radio::V1_6::RadioResponseInfo& info) {
     rspInfo = info;
@@ -1199,3 +1207,11 @@
     parent_v1_6.notify(info.serial);
     return Void();
 }
+
+Return<void> RadioResponse_v1_6::getCurrentCallsResponse_1_6(
+        const ::android::hardware::radio::V1_6::RadioResponseInfo& info,
+        const ::android::hardware::hidl_vec<::android::hardware::radio::V1_6::Call>& /*calls*/) {
+    rspInfo = info;
+    parent_v1_6.notify(info.serial);
+    return Void();
+}
diff --git a/renderscript/1.0/types.hal b/renderscript/1.0/types.hal
index 7c32188..bb39baa 100644
--- a/renderscript/1.0/types.hal
+++ b/renderscript/1.0/types.hal
@@ -170,7 +170,6 @@
 };
 
 // Script to Script
-@export(name="RsScriptCall")
 struct ScriptCall {
     ForEachStrategy strategy;
     uint32_t        xStart;
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 91%
rename from keymint/aidl/android/hardware/keymint/Tag.aidl
rename to security/keymint/aidl/android/hardware/security/keymint/Tag.aidl
index 46da096..3bc3f16 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
@@ -46,7 +46,7 @@
      *
      * Must be hardware-enforced.
      */
-    PURPOSE = (2 << 28) | 1, /* TagType:ENUM_REP */
+    PURPOSE = (2 << 28) /* TagType:ENUM_REP */ | 1,
 
     /**
      * Tag::ALGORITHM specifies the cryptographic algorithm with which the key is used.  This tag
@@ -55,7 +55,7 @@
      *
      * Must be hardware-enforced.
      */
-    ALGORITHM = (1 << 28) | 2, /* TagType:ENUM */
+    ALGORITHM = (1 << 28) /* TagType:ENUM */ | 2,
 
     /**
      * Tag::KEY_SIZE pecifies the size, in bits, of the key, measuring in the normal way for the
@@ -67,7 +67,7 @@
      *
      * Must be hardware-enforced.
      */
-    KEY_SIZE = (3 << 28) | 3, /* TagType:UINT */
+    KEY_SIZE = (3 << 28) /* TagType:UINT */ | 3,
 
     /**
      * Tag::BLOCK_MODE specifies the block cipher mode(s) with which the key may be used.  This tag
@@ -80,8 +80,8 @@
      *
      * Must be hardware-enforced.
      */
-    BLOCK_MODE = (2 << 28) | 4,
-    /* BlockMode. */ /* TagType:ENUM_REP */
+    BLOCK_MODE = (2 << 28) /* TagType:ENUM_REP */ | 4,
+
 
     /**
      * Tag::DIGEST specifies the digest algorithms that may be used with the key to perform signing
@@ -95,7 +95,7 @@
      *
      * Must be hardware-enforced.
      */
-    DIGEST = (2 << 28) | 5, /* TagType:ENUM_REP */
+    DIGEST = (2 << 28) /* TagType:ENUM_REP */ | 5,
 
     /**
      * Tag::PADDING specifies the padding modes that may be used with the key.  This tag is relevant
@@ -123,7 +123,7 @@
      *
      * Must be hardware-enforced.
      */
-    PADDING = (2 << 28) | 6, /* TagType:ENUM_REP */
+    PADDING = (2 << 28) /* TagType:ENUM_REP */ | 6,
 
     /**
      * Tag::CALLER_NONCE specifies that the caller can provide a nonce for nonce-requiring
@@ -136,7 +136,7 @@
      *
      * Must be hardware-enforced.
      */
-    CALLER_NONCE = (7 << 28) | 7, /* TagType:BOOL */
+    CALLER_NONCE = (7 << 28) /* TagType:BOOL */ | 7,
 
     /**
      * Tag::MIN_MAC_LENGTH specifies the minimum length of MAC that can be requested or verified
@@ -149,7 +149,7 @@
      *
      * Must be hardware-enforced.
      */
-    MIN_MAC_LENGTH = (3 << 28) | 8, /* TagType:UINT */
+    MIN_MAC_LENGTH = (3 << 28) /* TagType:UINT */ | 8,
 
     // Tag 9 reserved
 
@@ -160,7 +160,7 @@
      *
      * Must be hardware-enforced.
      */
-    EC_CURVE = (1 << 28) | 10, /* TagType:ENUM */
+    EC_CURVE = (1 << 28) /* TagType:ENUM */ | 10,
 
     /**
      * Tag::RSA_PUBLIC_EXPONENT specifies the value of the public exponent for an RSA key pair.
@@ -174,7 +174,7 @@
      *
      * Must be hardware-enforced.
      */
-    RSA_PUBLIC_EXPONENT = (5 << 28) | 200, /* TagType:ULONG */
+    RSA_PUBLIC_EXPONENT = (5 << 28) /* TagType:ULONG */ | 200,
 
     // Tag 201 reserved
 
@@ -185,7 +185,7 @@
      *
      * Must be hardware-enforced.
      */
-    INCLUDE_UNIQUE_ID = (7 << 28) | 202, /* TagType:BOOL */
+    INCLUDE_UNIQUE_ID = (7 << 28) /* TagType:BOOL */ | 202,
 
     /**
      * TODO(seleneh) this tag needs to be deleted from all codes.
@@ -202,7 +202,7 @@
      *
      * Must be hardware-enforced.
      */
-    BLOB_USAGE_REQUIREMENTS = (1 << 28) | 301, /* TagType:ENUM */
+    BLOB_USAGE_REQUIREMENTS = (1 << 28) /* TagType:ENUM */ | 301,
 
     /**
      * Tag::BOOTLOADER_ONLY specifies only the bootloader can use the key.
@@ -212,7 +212,7 @@
      *
      * Must be hardware-enforced.
      */
-    BOOTLOADER_ONLY = (7 << 28) | 302, /* TagType:BOOL */
+    BOOTLOADER_ONLY = (7 << 28) /* TagType:BOOL */ | 302,
 
     /**
      * Tag::ROLLBACK_RESISTANCE specifies that the key has rollback resistance, meaning that when
@@ -227,16 +227,16 @@
      *
      * Must be hardwared-enforced.
      */
-    ROLLBACK_RESISTANCE = (7 << 28) | 303, /* TagType:BOOL */
+    ROLLBACK_RESISTANCE = (7 << 28) /* TagType:BOOL */ | 303,
 
     // Reserved for future use.
-    HARDWARE_TYPE = (1 << 28) | 304, /* TagType:ENUM */
+    HARDWARE_TYPE = (1 << 28) /* TagType:ENUM */ | 304,
 
     /**
      * Keys tagged with EARLY_BOOT_ONLY may only be used, or created, during early boot, until
      * IKeyMintDevice::earlyBootEnded() is called.
      */
-    EARLY_BOOT_ONLY = (7 << 28) | 305, /* TagType:BOOL */
+    EARLY_BOOT_ONLY = (7 << 28) /* TagType:BOOL */ | 305,
 
     /**
      * Tag::ACTIVE_DATETIME specifies the date and time at which the key becomes active, in
@@ -245,8 +245,7 @@
      *
      * Need not be hardware-enforced.
      */
-    ACTIVE_DATETIME = (6 << 28) | 400,
-    /* Start of validity. */ /* TagType:DATE */
+    ACTIVE_DATETIME = (6 << 28) /* TagType:DATE */ | 400,
 
     /**
      * Tag::ORIGINATION_EXPIRE_DATETIME specifies the date and time at which the key expires for
@@ -258,7 +257,7 @@
      *
      * Need not be hardware-enforced.
      */
-    ORIGINATION_EXPIRE_DATETIME = (6 << 28) | 401, /* TagType:DATE */
+    ORIGINATION_EXPIRE_DATETIME = (6 << 28) /* TagType:DATE */ | 401,
 
     /**
      * Tag::USAGE_EXPIRE_DATETIME specifies the date and time at which the key expires for
@@ -270,7 +269,7 @@
      *
      * Need not be hardware-enforced.
      */
-    USAGE_EXPIRE_DATETIME = (6 << 28) | 402, /* TagType:DATE */
+    USAGE_EXPIRE_DATETIME = (6 << 28) /* TagType:DATE */ | 402,
 
     /**
      * TODO(seleneh) this tag need to be deleted.
@@ -295,7 +294,7 @@
      *
      * Must be hardware-enforced.
      */
-    MIN_SECONDS_BETWEEN_OPS = (3 << 28) | 403, /* TagType:UINT */
+    MIN_SECONDS_BETWEEN_OPS = (3 << 28) /* TagType:UINT */ | 403,
 
     /**
      * Tag::MAX_USES_PER_BOOT specifies the maximum number of times that a key may be used between
@@ -315,14 +314,14 @@
      *
      * Must be hardware-enforced.
      */
-    MAX_USES_PER_BOOT = (3 << 28) | 404, /* TagType:UINT */
+    MAX_USES_PER_BOOT = (3 << 28) /* TagType:UINT */ | 404,
 
     /**
      * Tag::USER_ID specifies the ID of the Android user that is permitted to use the key.
      *
      * Must not be hardware-enforced.
      */
-    USER_ID = (3 << 28) | 501, /* TagType:UINT */
+    USER_ID = (3 << 28) /* TagType:UINT */ | 501,
 
     /**
      * Tag::USER_SECURE_ID specifies that a key may only be used under a particular secure user
@@ -355,7 +354,7 @@
      *
      * Must be hardware-enforced.
      */
-    USER_SECURE_ID = (10 << 28) | 502, /* TagType:ULONG_REP */
+    USER_SECURE_ID = (10 << 28) /* TagType:ULONG_REP */ | 502,
 
     /**
      * Tag::NO_AUTH_REQUIRED specifies that no authentication is required to use this key.  This tag
@@ -363,7 +362,7 @@
      *
      * Must be hardware-enforced.
      */
-    NO_AUTH_REQUIRED = (7 << 28) | 503, /* TagType:BOOL */
+    NO_AUTH_REQUIRED = (7 << 28) /* TagType:BOOL */ | 503,
 
     /**
      * Tag::USER_AUTH_TYPE specifies the types of user authenticators that may be used to authorize
@@ -382,7 +381,7 @@
      *
      * Must be hardware-enforced.
      */
-    USER_AUTH_TYPE = (1 << 28) | 504, /* TagType:ENUM */
+    USER_AUTH_TYPE = (1 << 28) /* TagType:ENUM */ | 504,
 
     /**
      * Tag::AUTH_TIMEOUT specifies the time in seconds for which the key is authorized for use,
@@ -396,7 +395,7 @@
      *
      * Must be hardware-enforced.
      */
-    AUTH_TIMEOUT = (3 << 28) | 505, /* TagType:UINT */
+    AUTH_TIMEOUT = (3 << 28) /* TagType:UINT */ | 505,
 
     /**
      * Tag::ALLOW_WHILE_ON_BODY specifies that the key may be used after authentication timeout if
@@ -404,7 +403,7 @@
      *
      * Cannot be hardware-enforced.
      */
-    ALLOW_WHILE_ON_BODY = (7 << 28) | 506, /* TagType:BOOL */
+    ALLOW_WHILE_ON_BODY = (7 << 28) /* TagType:BOOL */ | 506,
 
     /**
      * TRUSTED_USER_PRESENCE_REQUIRED is an optional feature that specifies that this key must be
@@ -451,7 +450,7 @@
      *
      * Must be hardware-enforced.
      */
-    TRUSTED_USER_PRESENCE_REQUIRED = (7 << 28) | 507, /* TagType:BOOL */
+    TRUSTED_USER_PRESENCE_REQUIRED = (7 << 28) /* TagType:BOOL */ | 507,
 
     /** Tag::TRUSTED_CONFIRMATION_REQUIRED is only applicable to keys with KeyPurpose SIGN, and
      *  specifies that this key must not be usable unless the user provides confirmation of the data
@@ -464,7 +463,7 @@
      *
      * Must be hardware-enforced.
      */
-    TRUSTED_CONFIRMATION_REQUIRED = (7 << 28) | 508, /* TagType:BOOL */
+    TRUSTED_CONFIRMATION_REQUIRED = (7 << 28) /* TagType:BOOL */ | 508,
 
     /**
      * Tag::UNLOCKED_DEVICE_REQUIRED specifies that the key may only be used when the device is
@@ -472,7 +471,7 @@
      *
      * Must be software-enforced.
      */
-    UNLOCKED_DEVICE_REQUIRED = (7 << 28) | 509, /* TagType:BOOL */
+    UNLOCKED_DEVICE_REQUIRED = (7 << 28) /* TagType:BOOL */ | 509,
 
     /**
      * Tag::APPLICATION_ID.  When provided to generateKey or importKey, this tag specifies data
@@ -488,7 +487,7 @@
      *
      * Must never appear in KeyCharacteristics.
      */
-    APPLICATION_ID = (9 << 28) | 601, /* TagType:BYTES */
+    APPLICATION_ID = (9 << 28) /* TagType:BYTES */ | 601,
 
     /*
      * Semantically unenforceable tags, either because they have no specific meaning or because
@@ -509,7 +508,7 @@
      *
      * Must never appear in KeyCharacteristics.
      */
-    APPLICATION_DATA = (9 << 28) | 700, /* TagType:BYTES */
+    APPLICATION_DATA = (9 << 28) /* TagType:BYTES */ | 700,
 
     /**
      * Tag::CREATION_DATETIME specifies the date and time the key was created, in milliseconds since
@@ -518,7 +517,7 @@
      * Tag::CREATED is informational only, and not enforced by anything.  Must be in the
      * software-enforced list, if provided.
      */
-    CREATION_DATETIME = (6 << 28) | 701, /* TagType:DATE */
+    CREATION_DATETIME = (6 << 28) /* TagType:DATE */ | 701,
 
     /**
      * Tag::ORIGIN specifies where the key was created, if known.  This tag must not be specified
@@ -527,7 +526,7 @@
      *
      * Must be hardware-enforced.
      */
-    ORIGIN = (1 << 28) | 702, /* TagType:ENUM */
+    ORIGIN = (1 << 28) /* TagType:ENUM */ | 702,
 
     // 703 is unused.
 
@@ -539,7 +538,7 @@
      *
      * Must never appear in KeyCharacteristics.
      */
-    ROOT_OF_TRUST = (9 << 28) | 704, /* TagType:BYTES */
+    ROOT_OF_TRUST = (9 << 28) /* TagType:BYTES */ | 704,
 
     /**
      * Tag::OS_VERSION specifies the system OS version with which the key may be used.  This tag is
@@ -562,7 +561,7 @@
      *
      * Must be hardware-enforced.
      */
-    OS_VERSION = (3 << 28) | 705, /* TagType:UINT */
+    OS_VERSION = (3 << 28) /* TagType:UINT */ | 705,
 
     /**
      * Tag::OS_PATCHLEVEL specifies the system security patch level with which the key may be used.
@@ -583,7 +582,7 @@
      *
      * Must be hardware-enforced.
      */
-    OS_PATCHLEVEL = (3 << 28) | 706, /* TagType:UINT */
+    OS_PATCHLEVEL = (3 << 28) /* TagType:UINT */ | 706,
 
     /**
      * Tag::UNIQUE_ID specifies a unique, time-based identifier.  This tag is never provided to or
@@ -617,7 +616,7 @@
      *
      * Must be hardware-enforced.
      */
-    UNIQUE_ID = (9 << 28) | 707, /* TagType:BYTES */
+    UNIQUE_ID = (9 << 28) /* TagType:BYTES */ | 707,
 
     /**
      * Tag::ATTESTATION_CHALLENGE is used to deliver a "challenge" value to the attestKey() method,
@@ -626,7 +625,7 @@
      *
      * Must never appear in KeyCharacteristics.
      */
-    ATTESTATION_CHALLENGE = (9 << 28) | 708, /* TagType:BYTES */
+    ATTESTATION_CHALLENGE = (9 << 28) /* TagType:BYTES */ | 708,
 
     /**
      * Tag::ATTESTATION_APPLICATION_ID identifies the set of applications which may use a key, used
@@ -652,7 +651,7 @@
      *
      * Cannot be hardware-enforced.
      */
-    ATTESTATION_APPLICATION_ID = (9 << 28) | 709, /* TagType:BYTES */
+    ATTESTATION_APPLICATION_ID = (9 << 28) /* TagType:BYTES */ | 709,
 
     /**
      * Tag::ATTESTATION_ID_BRAND provides the device's brand name, as returned by Build.BRAND in
@@ -665,7 +664,7 @@
      *
      * Must never appear in KeyCharacteristics.
      */
-    ATTESTATION_ID_BRAND = (9 << 28) | 710, /* TagType:BYTES */
+    ATTESTATION_ID_BRAND = (9 << 28) /* TagType:BYTES */ | 710,
 
     /**
      * Tag::ATTESTATION_ID_DEVICE provides the device's device name, as returned by Build.DEVICE in
@@ -678,7 +677,7 @@
      *
      * Must never appear in KeyCharacteristics.
      */
-    ATTESTATION_ID_DEVICE = (9 << 28) | 711, /* TagType:BYTES */
+    ATTESTATION_ID_DEVICE = (9 << 28) /* TagType:BYTES */ | 711,
 
     /**
      * Tag::ATTESTATION_ID_PRODUCT provides the device's product name, as returned by Build.PRODUCT
@@ -691,7 +690,7 @@
      *
      * Must never appear in KeyCharacteristics.
      */
-    ATTESTATION_ID_PRODUCT = (9 << 28) | 712, /* TagType:BYTES */
+    ATTESTATION_ID_PRODUCT = (9 << 28) /* TagType:BYTES */ | 712,
 
     /**
      * Tag::ATTESTATION_ID_SERIAL the device's serial number.  This field must be set only when
@@ -703,7 +702,7 @@
      *
      * Must never appear in KeyCharacteristics.
      */
-    ATTESTATION_ID_SERIAL = (9 << 28) | 713, /* TagType:BYTES */
+    ATTESTATION_ID_SERIAL = (9 << 28) /* TagType:BYTES */ | 713,
 
     /**
      * Tag::ATTESTATION_ID_IMEI provides the IMEIs for all radios on the device to attestKey().
@@ -715,7 +714,7 @@
      *
      * Must never appear in KeyCharacteristics.
      */
-    ATTESTATION_ID_IMEI = (9 << 28) | 714, /* TagType:BYTES */
+    ATTESTATION_ID_IMEI = (9 << 28) /* TagType:BYTES */ | 714,
 
     /**
      * Tag::ATTESTATION_ID_MEID provides the MEIDs for all radios on the device to attestKey().
@@ -727,7 +726,7 @@
      *
      * Must never appear in KeyCharacteristics.
      */
-    ATTESTATION_ID_MEID = (9 << 28) | 715, /* TagType:BYTES */
+    ATTESTATION_ID_MEID = (9 << 28) /* TagType:BYTES */ | 715,
 
     /**
      * Tag::ATTESTATION_ID_MANUFACTURER provides the device's manufacturer name, as returned by
@@ -740,7 +739,7 @@
      *
      * Must never appear in KeyCharacteristics.
      */
-    ATTESTATION_ID_MANUFACTURER = (9 << 28) | 716, /* TagType:BYTES */
+    ATTESTATION_ID_MANUFACTURER = (9 << 28) /* TagType:BYTES */ | 716,
 
     /**
      * Tag::ATTESTATION_ID_MODEL provides the device's model name, as returned by Build.MODEL in
@@ -753,7 +752,7 @@
      *
      * Must never appear in KeyCharacteristics.
      */
-    ATTESTATION_ID_MODEL = (9 << 28) | 717, /* TagType:BYTES */
+    ATTESTATION_ID_MODEL = (9 << 28) /* TagType:BYTES */ | 717,
 
     /**
      * Tag::VENDOR_PATCHLEVEL specifies the vendor image security patch level with which the key may
@@ -775,7 +774,7 @@
      *
      * Must be hardware-enforced.
      */
-    VENDOR_PATCHLEVEL = (3 << 28) | 718, /* TagType:UINT */
+    VENDOR_PATCHLEVEL = (3 << 28) /* TagType:UINT */ | 718,
 
     /**
      * Tag::BOOT_PATCHLEVEL specifies the boot image (kernel) security patch level with which the
@@ -795,7 +794,7 @@
      *
      * Must be hardware-enforced.
      */
-    BOOT_PATCHLEVEL = (3 << 28) | 719, /* TagType:UINT */
+    BOOT_PATCHLEVEL = (3 << 28) /* TagType:UINT */ | 719,
 
     /**
      * DEVICE_UNIQUE_ATTESTATION is an argument to IKeyMintDevice::attestKey().  It indicates that
@@ -811,7 +810,7 @@
      * IKeyMintDevice implementations that support device-unique attestation MUST add the
      * DEVICE_UNIQUE_ATTESTATION tag to device-unique attestations.
      */
-    DEVICE_UNIQUE_ATTESTATION = (7 << 28) | 720, /* TagType:BOOL */
+    DEVICE_UNIQUE_ATTESTATION = (7 << 28) /* TagType:BOOL */ | 720,
 
     /**
      * IDENTITY_CREDENTIAL_KEY is never used by IKeyMintDevice, is not a valid argument to key
@@ -819,7 +818,7 @@
      * attestation.  It is used in attestations produced by the IIdentityCredential HAL when that
      * HAL attests to Credential Keys.  IIdentityCredential produces KeyMint-style attestations.
      */
-    IDENTITY_CREDENTIAL_KEY = (7 << 28) | 721, /* TagType:BOOL */
+    IDENTITY_CREDENTIAL_KEY = (7 << 28) /* TagType:BOOL */ | 721,
 
     /**
      * To prevent keys from being compromised if an attacker acquires read access to system / kernel
@@ -836,7 +835,7 @@
      * ErrorCode::INVALID_OPERATION is returned when a key with Tag::STORAGE_KEY is provided to
      * begin().
      */
-    STORAGE_KEY = (7 << 28) | 722, /* TagType:BOOL */
+    STORAGE_KEY = (7 << 28) /* TagType:BOOL */ | 722,
 
     /**
      * Tag::ASSOCIATED_DATA Provides "associated data" for AES-GCM encryption or decryption.  This
@@ -845,7 +844,7 @@
      *
      * Must never appear KeyCharacteristics.
      */
-    ASSOCIATED_DATA = (9 << 28) | 1000, /* TagType:BYTES */
+    ASSOCIATED_DATA = (9 << 28) /* TagType:BYTES */ | 1000,
 
     /**
      * Tag::NONCE is used to provide or return a nonce or Initialization Vector (IV) for AES-GCM,
@@ -860,7 +859,7 @@
      *
      * Must never appear in KeyCharacteristics.
      */
-    NONCE = (9 << 28) | 1001, /* TagType:BYTES */
+    NONCE = (9 << 28) /* TagType:BYTES */ | 1001,
 
     /**
      * Tag::MAC_LENGTH provides the requested length of a MAC or GCM authentication tag, in bits.
@@ -871,7 +870,7 @@
      *
      * Must never appear in KeyCharacteristics.
      */
-    MAC_LENGTH = (3 << 28) | 1003, /* TagType:UINT */
+    MAC_LENGTH = (3 << 28) /* TagType:UINT */ | 1003,
 
     /**
      * Tag::RESET_SINCE_ID_ROTATION specifies whether the device has been factory reset since the
@@ -879,7 +878,7 @@
      *
      * Must never appear in KeyCharacteristics.
      */
-    RESET_SINCE_ID_ROTATION = (7 << 28) | 1004, /* TagType:BOOL */
+    RESET_SINCE_ID_ROTATION = (7 << 28) /* TagType:BOOL */ | 1004,
 
     /**
      * Tag::CONFIRMATION_TOKEN is used to deliver a cryptographic token proving that the user
@@ -888,5 +887,5 @@
      *
      * Must never appear in KeyCharacteristics.
      */
-    CONFIRMATION_TOKEN = (9 << 28) | 1005, /* TagType:BYTES */
+    CONFIRMATION_TOKEN = (9 << 28) /* TagType:BYTES */ | 1005,
 }
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 94%
rename from keymint/aidl/vts/functional/KeyMintAidlTestBase.h
rename to security/keymint/aidl/vts/functional/KeyMintAidlTestBase.h
index 2948c41..052736b 100644
--- a/keymint/aidl/vts/functional/KeyMintAidlTestBase.h
+++ b/security/keymint/aidl/vts/functional/KeyMintAidlTestBase.h
@@ -14,25 +14,20 @@
  * limitations under the License.
  */
 
-#ifndef VTS_KEYMINT_AIDL_TEST_UTILS_H
-#define VTS_KEYMINT_AIDL_TEST_UTILS_H
-
 #pragma once
 
 #include <aidl/Gtest.h>
 #include <aidl/Vintf.h>
-#include <android/hardware/keymint/ErrorCode.h>
-#include <android/hardware/keymint/IKeyMintDevice.h>
 #include <binder/IServiceManager.h>
 #include <binder/ProcessState.h>
 #include <gtest/gtest.h>
 
-#include <keymintSupport/authorization_set.h>
+#include <android/hardware/security/keymint/ErrorCode.h>
+#include <android/hardware/security/keymint/IKeyMintDevice.h>
 
-namespace android {
-namespace hardware {
-namespace keymint {
-namespace test {
+#include <keymint_support/authorization_set.h>
+
+namespace android::hardware::security::keymint::test {
 
 using ::android::sp;
 using binder::Status;
@@ -189,9 +184,4 @@
                              testing::ValuesIn(KeyMintAidlTestBase::build_params()), \
                              android::PrintInstanceNameToString)
 
-}  // namespace test
-}  // namespace keymint
-}  // namespace hardware
-}  // namespace android
-
-#endif  // VTS_KEYMINT_AIDL_TEST_UTILS_H
+}  // namespace android::hardware::security::keymint::test
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 95%
rename from keymint/support/attestation_record.cpp
rename to security/keymint/support/attestation_record.cpp
index e565974..1b07495 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/hardware/security/keymint/Tag.h>
+#include <android/hardware/security/keymint/TagType.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 <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); }
@@ -327,9 +326,8 @@
 }
 
 ErrorCode parse_root_of_trust(const uint8_t* asn1_key_desc, size_t asn1_key_desc_len,
-                              vector<uint8_t>* verified_boot_key,
-                              keymint_verified_boot_t* verified_boot_state, bool* device_locked,
-                              vector<uint8_t>* verified_boot_hash) {
+                              vector<uint8_t>* verified_boot_key, VerifiedBoot* verified_boot_state,
+                              bool* device_locked, vector<uint8_t>* verified_boot_hash) {
     if (!verified_boot_key || !verified_boot_state || !device_locked || !verified_boot_hash) {
         LOG(ERROR) << AT << "null pointer input(s)";
         return ErrorCode::INVALID_ARGUMENT;
@@ -359,8 +357,8 @@
     verified_boot_key->resize(vb_key->length);
     memcpy(verified_boot_key->data(), vb_key->data, vb_key->length);
 
-    *verified_boot_state = static_cast<keymint_verified_boot_t>(
-            ASN1_ENUMERATED_get(root_of_trust->verified_boot_state));
+    *verified_boot_state =
+            static_cast<VerifiedBoot>(ASN1_ENUMERATED_get(root_of_trust->verified_boot_state));
     if (!verified_boot_state) {
         LOG(ERROR) << AT << " Failed verified boot state parsing";
         return ErrorCode::INVALID_ARGUMENT;
@@ -382,6 +380,4 @@
     return ErrorCode::OK;  // KM_ERROR_OK;
 }
 
-}  // namespace keymint
-}  // namespace hardware
-}  // namespace android
+}  // namespace android::hardware::security::keymint
diff --git a/security/keymint/support/authorization_set.cpp b/security/keymint/support/authorization_set.cpp
new file mode 100644
index 0000000..e2aac9a
--- /dev/null
+++ b/security/keymint/support/authorization_set.cpp
@@ -0,0 +1,243 @@
+/*
+ * Copyright 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 <keymint_support/authorization_set.h>
+
+#include <assert.h>
+#include <sstream>
+
+#include <android-base/logging.h>
+
+#include <android/hardware/security/keymint/Algorithm.h>
+#include <android/hardware/security/keymint/BlockMode.h>
+#include <android/hardware/security/keymint/Digest.h>
+#include <android/hardware/security/keymint/KeyParameter.h>
+#include <android/hardware/security/keymint/KeyPurpose.h>
+#include <android/hardware/security/keymint/TagType.h>
+
+namespace android::hardware::security::keymint {
+
+void AuthorizationSet::Sort() {
+    std::sort(data_.begin(), data_.end());
+}
+
+void AuthorizationSet::Deduplicate() {
+    if (data_.empty()) return;
+
+    Sort();
+    std::vector<KeyParameter> result;
+
+    auto curr = data_.begin();
+    auto prev = curr++;
+    for (; curr != data_.end(); ++prev, ++curr) {
+        if (prev->tag == Tag::INVALID) continue;
+
+        if (*prev != *curr) {
+            result.push_back(std::move(*prev));
+        }
+    }
+    result.push_back(std::move(*prev));
+
+    std::swap(data_, result);
+}
+
+void AuthorizationSet::Union(const AuthorizationSet& other) {
+    data_.insert(data_.end(), other.data_.begin(), other.data_.end());
+    Deduplicate();
+}
+
+void AuthorizationSet::Subtract(const AuthorizationSet& other) {
+    Deduplicate();
+
+    auto i = other.begin();
+    while (i != other.end()) {
+        int pos = -1;
+        do {
+            pos = find(i->tag, pos);
+            if (pos != -1 && (*i == data_[pos])) {
+                data_.erase(data_.begin() + pos);
+                break;
+            }
+        } while (pos != -1);
+        ++i;
+    }
+}
+
+KeyParameter& AuthorizationSet::operator[](int at) {
+    return data_[at];
+}
+
+const KeyParameter& AuthorizationSet::operator[](int at) const {
+    return data_[at];
+}
+
+void AuthorizationSet::Clear() {
+    data_.clear();
+}
+
+size_t AuthorizationSet::GetTagCount(Tag tag) const {
+    size_t count = 0;
+    for (int pos = -1; (pos = find(tag, pos)) != -1;) ++count;
+    return count;
+}
+
+int AuthorizationSet::find(Tag tag, int begin) const {
+    auto iter = data_.begin() + (1 + begin);
+
+    while (iter != data_.end() && iter->tag != tag) ++iter;
+
+    if (iter != data_.end()) return iter - data_.begin();
+    return -1;
+}
+
+bool AuthorizationSet::erase(int index) {
+    auto pos = data_.begin() + index;
+    if (pos != data_.end()) {
+        data_.erase(pos);
+        return true;
+    }
+    return false;
+}
+
+NullOr<const KeyParameter&> AuthorizationSet::GetEntry(Tag tag) const {
+    int pos = find(tag);
+    if (pos == -1) return {};
+    return data_[pos];
+}
+
+AuthorizationSetBuilder& AuthorizationSetBuilder::RsaKey(uint32_t key_size,
+                                                         uint64_t public_exponent) {
+    Authorization(TAG_ALGORITHM, Algorithm::RSA);
+    Authorization(TAG_KEY_SIZE, key_size);
+    Authorization(TAG_RSA_PUBLIC_EXPONENT, public_exponent);
+    return *this;
+}
+
+AuthorizationSetBuilder& AuthorizationSetBuilder::EcdsaKey(uint32_t key_size) {
+    Authorization(TAG_ALGORITHM, Algorithm::EC);
+    Authorization(TAG_KEY_SIZE, key_size);
+    return *this;
+}
+
+AuthorizationSetBuilder& AuthorizationSetBuilder::EcdsaKey(EcCurve curve) {
+    Authorization(TAG_ALGORITHM, Algorithm::EC);
+    Authorization(TAG_EC_CURVE, curve);
+    return *this;
+}
+
+AuthorizationSetBuilder& AuthorizationSetBuilder::AesKey(uint32_t key_size) {
+    Authorization(TAG_ALGORITHM, Algorithm::AES);
+    return Authorization(TAG_KEY_SIZE, key_size);
+}
+
+AuthorizationSetBuilder& AuthorizationSetBuilder::TripleDesKey(uint32_t key_size) {
+    Authorization(TAG_ALGORITHM, Algorithm::TRIPLE_DES);
+    return Authorization(TAG_KEY_SIZE, key_size);
+}
+
+AuthorizationSetBuilder& AuthorizationSetBuilder::HmacKey(uint32_t key_size) {
+    Authorization(TAG_ALGORITHM, Algorithm::HMAC);
+    Authorization(TAG_KEY_SIZE, key_size);
+    return SigningKey();
+}
+
+AuthorizationSetBuilder& AuthorizationSetBuilder::RsaSigningKey(uint32_t key_size,
+                                                                uint64_t public_exponent) {
+    RsaKey(key_size, public_exponent);
+    return SigningKey();
+}
+
+AuthorizationSetBuilder& AuthorizationSetBuilder::RsaEncryptionKey(uint32_t key_size,
+                                                                   uint64_t public_exponent) {
+    RsaKey(key_size, public_exponent);
+    return EncryptionKey();
+}
+
+AuthorizationSetBuilder& AuthorizationSetBuilder::EcdsaSigningKey(uint32_t key_size) {
+    EcdsaKey(key_size);
+    return SigningKey();
+}
+
+AuthorizationSetBuilder& AuthorizationSetBuilder::EcdsaSigningKey(EcCurve curve) {
+    EcdsaKey(curve);
+    return SigningKey();
+}
+
+AuthorizationSetBuilder& AuthorizationSetBuilder::AesEncryptionKey(uint32_t key_size) {
+    AesKey(key_size);
+    return EncryptionKey();
+}
+
+AuthorizationSetBuilder& AuthorizationSetBuilder::TripleDesEncryptionKey(uint32_t key_size) {
+    TripleDesKey(key_size);
+    return EncryptionKey();
+}
+
+AuthorizationSetBuilder& AuthorizationSetBuilder::SigningKey() {
+    Authorization(TAG_PURPOSE, KeyPurpose::SIGN);
+    return Authorization(TAG_PURPOSE, KeyPurpose::VERIFY);
+}
+
+AuthorizationSetBuilder& AuthorizationSetBuilder::EncryptionKey() {
+    Authorization(TAG_PURPOSE, KeyPurpose::ENCRYPT);
+    return Authorization(TAG_PURPOSE, KeyPurpose::DECRYPT);
+}
+
+AuthorizationSetBuilder& AuthorizationSetBuilder::NoDigestOrPadding() {
+    Authorization(TAG_DIGEST, Digest::NONE);
+    return Authorization(TAG_PADDING, PaddingMode::NONE);
+}
+
+AuthorizationSetBuilder& AuthorizationSetBuilder::EcbMode() {
+    return Authorization(TAG_BLOCK_MODE, BlockMode::ECB);
+}
+
+AuthorizationSetBuilder& AuthorizationSetBuilder::GcmModeMinMacLen(uint32_t minMacLength) {
+    return BlockMode(BlockMode::GCM)
+            .Padding(PaddingMode::NONE)
+            .Authorization(TAG_MIN_MAC_LENGTH, minMacLength);
+}
+
+AuthorizationSetBuilder& AuthorizationSetBuilder::GcmModeMacLen(uint32_t macLength) {
+    return BlockMode(BlockMode::GCM)
+            .Padding(PaddingMode::NONE)
+            .Authorization(TAG_MAC_LENGTH, macLength);
+}
+
+AuthorizationSetBuilder& AuthorizationSetBuilder::BlockMode(
+        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<keymint::Digest> digests) {
+    for (auto digest : digests) {
+        push_back(TAG_DIGEST, digest);
+    }
+    return *this;
+}
+
+AuthorizationSetBuilder& AuthorizationSetBuilder::Padding(
+        std::initializer_list<PaddingMode> paddingModes) {
+    for (auto paddingMode : paddingModes) {
+        push_back(TAG_PADDING, paddingMode);
+    }
+    return *this;
+}
+
+}  // 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 74%
rename from keymint/support/include/keymintSupport/attestation_record.h
rename to security/keymint/support/include/keymint_support/attestation_record.h
index 7a69789..0739569 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;
 
@@ -49,18 +43,18 @@
  */
 static const char kAttestionRecordOid[] = "1.3.6.1.4.1.11129.2.1.17";
 
-enum keymint_verified_boot_t {
-    KM_VERIFIED_BOOT_VERIFIED = 0,
-    KM_VERIFIED_BOOT_SELF_SIGNED = 1,
-    KM_VERIFIED_BOOT_UNVERIFIED = 2,
-    KM_VERIFIED_BOOT_FAILED = 3,
+enum class VerifiedBoot : uint8_t {
+    VERIFIED = 0,
+    SELF_SIGNED = 1,
+    UNVERIFIED = 2,
+    FAILED = 3,
 };
 
 struct RootOfTrust {
     SecurityLevel security_level;
     vector<uint8_t> verified_boot_key;
     vector<uint8_t> verified_boot_hash;
-    keymint_verified_boot_t verified_boot_state;
+    VerifiedBoot verified_boot_state;
     bool device_locked;
 };
 
@@ -87,9 +81,7 @@
 
 ErrorCode parse_root_of_trust(const uint8_t* asn1_key_desc, size_t asn1_key_desc_len,
                               std::vector<uint8_t>* verified_boot_key,
-                              keymint_verified_boot_t* verified_boot_state, bool* device_locked,
+                              VerifiedBoot* 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 86%
rename from keymint/support/include/keymintSupport/authorization_set.h
rename to security/keymint/support/include/keymint_support/authorization_set.h
index 141426a..0277200 100644
--- a/keymint/support/include/keymintSupport/authorization_set.h
+++ b/security/keymint/support/include/keymint_support/authorization_set.h
@@ -14,35 +14,26 @@
  * limitations under the License.
  */
 
-#ifndef SYSTEM_SECURITY_KEYSTORE_KM4_AUTHORIZATION_SET_H_
-#define SYSTEM_SECURITY_KEYSTORE_KM4_AUTHORIZATION_SET_H_
+#pragma once
 
 #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;
 
 class AuthorizationSetBuilder;
 
 /**
- * An ordered collection of KeyParameters. It provides memory ownership and some convenient
- * functionality for sorting, deduplicating, joining, and subtracting sets of KeyParameters.
- * For serialization, wrap the backing store of this structure in a vector<KeyParameter>.
+ * A collection of KeyParameters. It provides memory ownership and some convenient functionality for
+ * sorting, deduplicating, joining, and subtracting sets of KeyParameters.
  */
 class AuthorizationSet {
   public:
@@ -145,19 +136,16 @@
     /**
      * Returns iterator (pointer) to beginning of elems array, to enable STL-style iteration
      */
-    std::vector<KeyParameter>::const_iterator begin() const { return data_.begin(); }
+    auto begin() { return data_.begin(); }
+    auto begin() const { return data_.begin(); }
 
     /**
      * Returns iterator (pointer) one past end of elems array, to enable STL-style iteration
      */
-    std::vector<KeyParameter>::const_iterator end() const { return data_.end(); }
+    auto end() { return data_.end(); }
+    auto end() const { return data_.end(); }
 
     /**
-     * Modifies this Authorization set such that it only keeps the entries for which doKeep
-     * returns true.
-     */
-    void Filter(std::function<bool(const KeyParameter&)> doKeep);
-    /**
      * Returns the nth element of the set.
      * Like for std::vector::operator[] there is no range check performed. Use of out of range
      * indices is undefined.
@@ -230,9 +218,6 @@
         return result;
     }
 
-    void Serialize(std::ostream* out) const;
-    void Deserialize(std::istream* in);
-
   private:
     NullOr<const KeyParameter&> GetEntry(Tag tag) const;
 
@@ -322,8 +307,4 @@
     }
 };
 
-}  // namespace keymint
-}  // namespace hardware
-}  // namespace android
-
-#endif  // SYSTEM_SECURITY_KEYSTORE_KM4_AUTHORIZATION_SET_H_
+}  // namespace android::hardware::security::keymint
diff --git a/keymint/support/include/keymintSupport/key_param_output.h b/security/keymint/support/include/keymint_support/key_param_output.h
similarity index 66%
rename from keymint/support/include/keymintSupport/key_param_output.h
rename to security/keymint/support/include/keymint_support/key_param_output.h
index a35a981..b109105 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.
@@ -14,34 +14,29 @@
  * limitations under the License.
  */
 
-#ifndef HARDWARE_INTERFACES_KEYMINT_SUPPORT_INCLUDE_KEY_PARAM_OUTPUT_H_
-#define HARDWARE_INTERFACES_KEYMINT_SUPPORT_INCLUDE_KEY_PARAM_OUTPUT_H_
+#pragma once
 
 #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 +96,4 @@
     return os << toString(tag);
 }
 
-}  // namespace keymint
-}  // namespace hardware
-}  // namespace android
-
-#endif  // HARDWARE_INTERFACES_KEYMINT_SUPPORT_INCLUDE_KEY_PARAM_OUTPUT_H_
+}  // namespace android::hardware::security::keymint
diff --git a/keymint/support/include/keymintSupport/keymint_tags.h b/security/keymint/support/include/keymint_support/keymint_tags.h
similarity index 75%
rename from keymint/support/include/keymintSupport/keymint_tags.h
rename to security/keymint/support/include/keymint_support/keymint_tags.h
index f1060a9..d418fec 100644
--- a/keymint/support/include/keymintSupport/keymint_tags.h
+++ b/security/keymint/support/include/keymint_support/keymint_tags.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2019 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.
@@ -14,44 +14,32 @@
  * limitations under the License.
  */
 
-#ifndef HARDWARE_INTERFACES_KEYMINT_SUPPORT_INCLUDE_KEYMINT_TAGS_H_
-#define HARDWARE_INTERFACES_KEYMINT_SUPPORT_INCLUDE_KEYMINT_TAGS_H_
+#pragma once
 
-#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;
-
-// 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.
-// TODO(seleneh) we should delete this code when we stop supporting keymaster1
-// and deletes it.
-static const int32_t KM_TAG_DIGEST_OLD = static_cast<int32_t>(TagType::ENUM) | 5;
-static const int32_t KM_TAG_PADDING_OLD = static_cast<int32_t>(TagType::ENUM) | 7;
+namespace android::hardware::security::keymint {
 
 constexpr TagType typeFromTag(Tag tag) {
     return static_cast<TagType>(static_cast<uint32_t>(tag) & static_cast<uint32_t>(0xf0000000));
 }
 
 /**
- * TypedTag is a templatized version of Tag, which provides compile-time checking of
- * keymint tag types. Instances are convertible to Tag, so they can be used wherever
- * Tag is expected, and because they encode the tag type it's possible to create
- * function overloads that only operate on tags with a particular type.
+ * TypedTag is a templatized version of Tag, which provides compile-time checking of KeyMint tag
+ * types.  Instances are convertible to Tag, so they can be used wherever Tag is expected, and
+ * because they encode the tag type it's possible to create function overloads that only operate on
+ * tags with a particular type.
  */
 template <TagType tag_type, Tag tag>
 struct TypedTag {
@@ -337,78 +325,4 @@
     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
-
-#endif  // HARDWARE_INTERFACES_KEYMINT_SUPPORT_INCLUDE_KEYMINT_TAGS_H_
+}  // namespace android::hardware::security::keymint
diff --git a/keymint/support/include/keymintSupport/keymint_utils.h b/security/keymint/support/include/keymint_support/keymint_utils.h
similarity index 76%
rename from keymint/support/include/keymintSupport/keymint_utils.h
rename to security/keymint/support/include/keymint_support/keymint_utils.h
index aa1e93b..878b7df 100644
--- a/keymint/support/include/keymintSupport/keymint_utils.h
+++ b/security/keymint/support/include/keymint_support/keymint_utils.h
@@ -16,14 +16,9 @@
 
 #pragma once
 
-#ifndef HARDWARE_INTERFACES_KEYMINT_10_SUPPORT_KEYMINT_UTILS_H_
-#define HARDWARE_INTERFACES_KEYMINT_10_SUPPORT_KEYMINT_UTILS_H_
+#include <android/hardware/security/keymint/HardwareAuthToken.h>
 
-#include <android/hardware/keymint/HardwareAuthToken.h>
-
-namespace android {
-namespace hardware {
-namespace keymint {
+namespace android::hardware::security::keymint {
 
 using std::vector;
 
@@ -44,8 +39,4 @@
 uint32_t getOsVersion();
 uint32_t getOsPatchlevel();
 
-}  // namespace keymint
-}  // namespace hardware
-}  // namespace android
-
-#endif  // HARDWARE_INTERFACES_KEYMINT_10_SUPPORT_KEYMINT_UTILS_H_
+}  // namespace android::hardware::security::keymint
diff --git a/keymint/support/include/keymintSupport/openssl_utils.h b/security/keymint/support/include/keymint_support/openssl_utils.h
similarity index 64%
rename from keymint/support/include/keymintSupport/openssl_utils.h
rename to security/keymint/support/include/keymint_support/openssl_utils.h
index 39633ed..0878810 100644
--- a/keymint/support/include/keymintSupport/openssl_utils.h
+++ b/security/keymint/support/include/keymint_support/openssl_utils.h
@@ -1,5 +1,5 @@
 /*
- * Copyright 2017 The Android Open Source Project
+ * Copyright 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.
@@ -14,14 +14,15 @@
  * limitations under the License.
  */
 
-#ifndef HARDWARE_INTERFACES_KEYMINT_1_0_SUPPORT_OPENSSL_UTILS_H_
-#define HARDWARE_INTERFACES_KEYMINT_1_0_SUPPORT_OPENSSL_UTILS_H_
+#pragma once
 
-#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 +41,24 @@
 
 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;
 }
 
-#endif  // HARDWARE_INTERFACES_KEYMINT_1_0_SUPPORT_OPENSSL_UTILS_H_
+}  // namespace android::hardware::security::keymint
diff --git a/keymint/support/key_param_output.cpp b/security/keymint/support/key_param_output.cpp
similarity index 88%
rename from keymint/support/key_param_output.cpp
rename to security/keymint/support/key_param_output.cpp
index 6e33558..d8e2fff 100644
--- a/keymint/support/key_param_output.cpp
+++ b/security/keymint/support/key_param_output.cpp
@@ -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.
@@ -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 94%
rename from keymint/support/keymint_utils.cpp
rename to security/keymint/support/keymint_utils.cpp
index fd57cf5..63606f4 100644
--- a/keymint/support/keymint_utils.cpp
+++ b/security/keymint/support/keymint_utils.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2018 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.
@@ -16,13 +16,14 @@
 
 #include <regex.h>
 
-#include <android-base/properties.h>
-#include <hardware/hw_auth_token.h>
-#include <keymintSupport/keymint_utils.h>
-
 #include <arpa/inet.h>
 
-namespace android::hardware::keymint {
+#include <android-base/properties.h>
+#include <hardware/hw_auth_token.h>
+
+#include <keymint_support/keymint_utils.h>
+
+namespace android::hardware::security::keymint {
 
 namespace {
 
@@ -111,4 +112,4 @@
     return getOsPatchlevel(patchlevel.c_str());
 }
 
-}  // namespace android::hardware::keymint
+}  // namespace android::hardware::security::keymint
diff --git a/soundtrigger/2.1/ISoundTriggerHwCallback.hal b/soundtrigger/2.1/ISoundTriggerHwCallback.hal
index 42e851b..b7720b6 100644
--- a/soundtrigger/2.1/ISoundTriggerHwCallback.hal
+++ b/soundtrigger/2.1/ISoundTriggerHwCallback.hal
@@ -22,7 +22,6 @@
 /**
  * SoundTrigger HAL Callback interface. Obtained during SoundTrigger setup.
  */
-@hidl_callback
 interface ISoundTriggerHwCallback extends @2.0::ISoundTriggerHwCallback {
 
     /**
diff --git a/wifi/1.4/vts/functional/wifi_rtt_controller_hidl_test.cpp b/wifi/1.4/vts/functional/wifi_rtt_controller_hidl_test.cpp
index 3977cdd..72cde3c 100644
--- a/wifi/1.4/vts/functional/wifi_rtt_controller_hidl_test.cpp
+++ b/wifi/1.4/vts/functional/wifi_rtt_controller_hidl_test.cpp
@@ -191,6 +191,8 @@
     const auto& status =
         HIDL_INVOKE(wifi_rtt_controller_, rangeRequest_1_4, cmdId, configs);
     EXPECT_EQ(WifiStatusCode::SUCCESS, status.code);
+    // sleep for 2 seconds to wait for driver/firmware to complete RTT
+    sleep(2);
 }
 /*
  * rangeRequest_1_4
@@ -242,6 +244,8 @@
     const auto& status =
         HIDL_INVOKE(wifi_rtt_controller_, rangeRequest_1_4, cmdId, configs);
     EXPECT_EQ(WifiStatusCode::SUCCESS, status.code);
+    // sleep for 2 seconds to wait for driver/firmware to complete RTT
+    sleep(2);
 }
 
 /*
diff --git a/wifi/1.5/IWifiChip.hal b/wifi/1.5/IWifiChip.hal
index 2702759..e9caa3d 100644
--- a/wifi/1.5/IWifiChip.hal
+++ b/wifi/1.5/IWifiChip.hal
@@ -17,6 +17,7 @@
 package android.hardware.wifi@1.5;
 
 import @1.0::WifiStatus;
+import @1.0::IfaceType;
 import @1.5::IWifiApIface;
 import @1.0::IWifiIface;
 import @1.3::IWifiChip;
@@ -129,7 +130,6 @@
      */
     setMultiStaUseCase(MultiStaUseCase useCase) generates (WifiStatus status);
 
-
     /**
      * Create bridged IWifiApIface.
      *
@@ -167,4 +167,47 @@
      */
     removeIfaceInstanceFromBridgedApIface(string brIfaceName, string ifaceInstanceName)
         generates (WifiStatus status);
+
+    /**
+     * Representation of a Wi-Fi channel for Wi-Fi coex channel avoidance.
+     */
+    struct CoexUnsafeChannel {
+        /* The band of the channel */
+        WifiBand band;
+        /* The channel number */
+        uint32_t channel;
+        /** The power cap will be a maximum power value in dbm that is allowed to be transmitted by
+            the chip on this channel. A value of PowerCapConstant.NO_POWER_CAP means no limitation
+            on transmitted power is needed by the chip for this channel.
+        */
+        int32_t powerCapDbm;
+    };
+
+    enum PowerCapConstant : int32_t {
+        NO_POWER_CAP = 0x7FFFFFFF,
+    };
+
+    /**
+     * Invoked to indicate that the provided |CoexUnsafeChannels| should be avoided with the
+     * specified restrictions.
+     *
+     * Channel avoidance is a suggestion and should be done on a best-effort approach. If a provided
+     * channel is used, then the specified power cap should be applied.
+     *
+     * In addition, hard restrictions on the Wifi modes may be indicated by |IfaceType| bits
+     * (STA, AP, P2P, NAN, etc) in the |restrictions| bitfield. If a hard restriction is provided,
+     * then the channels should be completely avoided for the provided Wifi modes instead of by
+     * best-effort.
+     *
+     * @param unsafeChannels List of |CoexUnsafeChannels| to avoid.
+     * @param restrictions Bitset of |IfaceType| values indicating Wifi modes to completely avoid.
+     * @return status WifiStatus of the operation.
+     *         Possible status codes:
+     *         |WifiStatusCode.SUCCESS|,
+     *         |WifiStatusCode.ERROR_WIFI_CHIP_INVALID|,
+     *         |WifiStatusCode.ERROR_INVALID_ARGS|,
+     */
+    setCoexUnsafeChannels(
+        vec<CoexUnsafeChannel> unsafeChannels, bitfield<IfaceType> restrictions)
+            generates (WifiStatus status);
 };
diff --git a/wifi/1.5/default/hidl_struct_util.cpp b/wifi/1.5/default/hidl_struct_util.cpp
index 83d06fe..8e2e647 100644
--- a/wifi/1.5/default/hidl_struct_util.cpp
+++ b/wifi/1.5/default/hidl_struct_util.cpp
@@ -2800,6 +2800,47 @@
     }
     CHECK(false);
 }
+
+bool convertHidlCoexUnsafeChannelToLegacy(
+    const IWifiChip::CoexUnsafeChannel& hidl_unsafe_channel,
+    legacy_hal::wifi_coex_unsafe_channel* legacy_unsafe_channel) {
+    if (!legacy_unsafe_channel) {
+        return false;
+    }
+    *legacy_unsafe_channel = {};
+    switch (hidl_unsafe_channel.band) {
+        case WifiBand::BAND_24GHZ:
+            legacy_unsafe_channel->band = legacy_hal::WLAN_MAC_2_4_BAND;
+            break;
+        case WifiBand::BAND_5GHZ:
+            legacy_unsafe_channel->band = legacy_hal::WLAN_MAC_5_0_BAND;
+            break;
+        default:
+            return false;
+    };
+    legacy_unsafe_channel->channel = hidl_unsafe_channel.channel;
+    legacy_unsafe_channel->power_cap_dbm = hidl_unsafe_channel.powerCapDbm;
+    return true;
+}
+
+bool convertHidlVectorOfCoexUnsafeChannelToLegacy(
+    const std::vector<IWifiChip::CoexUnsafeChannel>& hidl_unsafe_channels,
+    std::vector<legacy_hal::wifi_coex_unsafe_channel>* legacy_unsafe_channels) {
+    if (!legacy_unsafe_channels) {
+        return false;
+    }
+    *legacy_unsafe_channels = {};
+    for (const auto& hidl_unsafe_channel : hidl_unsafe_channels) {
+        legacy_hal::wifi_coex_unsafe_channel legacy_unsafe_channel;
+        if (!hidl_struct_util::convertHidlCoexUnsafeChannelToLegacy(
+                hidl_unsafe_channel, &legacy_unsafe_channel)) {
+            return false;
+        }
+        legacy_unsafe_channels->push_back(legacy_unsafe_channel);
+    }
+    return true;
+}
+
 }  // namespace hidl_struct_util
 }  // namespace implementation
 }  // namespace V1_5
diff --git a/wifi/1.5/default/hidl_struct_util.h b/wifi/1.5/default/hidl_struct_util.h
index 49d8a12..feb47ef 100644
--- a/wifi/1.5/default/hidl_struct_util.h
+++ b/wifi/1.5/default/hidl_struct_util.h
@@ -71,6 +71,12 @@
     IfaceType hidl_interface_type);
 legacy_hal::wifi_multi_sta_use_case convertHidlMultiStaUseCaseToLegacy(
     IWifiChip::MultiStaUseCase use_case);
+bool convertHidlCoexUnsafeChannelToLegacy(
+    const IWifiChip::CoexUnsafeChannel& hidl_unsafe_channel,
+    legacy_hal::wifi_coex_unsafe_channel* legacy_unsafe_channel);
+bool convertHidlVectorOfCoexUnsafeChannelToLegacy(
+    const std::vector<IWifiChip::CoexUnsafeChannel>& hidl_unsafe_channels,
+    std::vector<legacy_hal::wifi_coex_unsafe_channel>* legacy_unsafe_channels);
 
 // STA iface conversion methods.
 bool convertLegacyFeaturesToHidlStaCapabilities(
diff --git a/wifi/1.5/default/wifi_chip.cpp b/wifi/1.5/default/wifi_chip.cpp
index dd39551..95478a4 100644
--- a/wifi/1.5/default/wifi_chip.cpp
+++ b/wifi/1.5/default/wifi_chip.cpp
@@ -116,8 +116,8 @@
     ifnames.push_back(buffer.data());
     if (is_bridged) {
         buffer.fill(0);
-        if (property_get("ro.vendor.wifi.sap.concurrent.interface",
-                         buffer.data(), nullptr) == 0) {
+        if (property_get("ro.vendor.wifi.sap.concurrent.iface", buffer.data(),
+                         nullptr) == 0) {
             return ifnames;
         }
         ifnames.push_back(buffer.data());
@@ -722,6 +722,15 @@
                            hidl_status_cb, use_case);
 }
 
+Return<void> WifiChip::setCoexUnsafeChannels(
+    const hidl_vec<CoexUnsafeChannel>& unsafeChannels,
+    hidl_bitfield<IfaceType> restrictions,
+    setCoexUnsafeChannels_cb hidl_status_cb) {
+    return validateAndCall(this, WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
+                           &WifiChip::setCoexUnsafeChannelsInternal,
+                           hidl_status_cb, unsafeChannels, restrictions);
+}
+
 void WifiChip::invalidateAndRemoveAllIfaces() {
     invalidateAndClearBridgedApAll();
     invalidateAndClearAll(ap_ifaces_);
@@ -1447,6 +1456,18 @@
     return createWifiStatusFromLegacyError(legacy_status);
 }
 
+WifiStatus WifiChip::setCoexUnsafeChannelsInternal(
+    std::vector<CoexUnsafeChannel> unsafe_channels, uint32_t restrictions) {
+    std::vector<legacy_hal::wifi_coex_unsafe_channel> legacy_unsafe_channels;
+    if (!hidl_struct_util::convertHidlVectorOfCoexUnsafeChannelToLegacy(
+            unsafe_channels, &legacy_unsafe_channels)) {
+        return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
+    }
+    auto legacy_status = legacy_hal_.lock()->setCoexUnsafeChannels(
+        legacy_unsafe_channels, restrictions);
+    return createWifiStatusFromLegacyError(legacy_status);
+}
+
 WifiStatus WifiChip::handleChipConfiguration(
     /* NONNULL */ std::unique_lock<std::recursive_mutex>* lock,
     ChipModeId mode_id) {
@@ -1820,8 +1841,8 @@
     } else {
         int num_ifaces_need_to_allocate = 2 - instances.size();
         for (int i = 0; i < num_ifaces_need_to_allocate; i++) {
-            std::string instance_name =
-                allocateApOrStaIfaceName(IfaceType::AP, startIdxOfApIface());
+            std::string instance_name = allocateApOrStaIfaceName(
+                IfaceType::AP, startIdxOfApIface() + i);
             if (!instance_name.empty()) {
                 instances.push_back(instance_name);
             }
diff --git a/wifi/1.5/default/wifi_chip.h b/wifi/1.5/default/wifi_chip.h
index bff8d68..95c122d 100644
--- a/wifi/1.5/default/wifi_chip.h
+++ b/wifi/1.5/default/wifi_chip.h
@@ -174,6 +174,10 @@
     Return<void> setMultiStaUseCase(
         MultiStaUseCase use_case,
         setMultiStaUseCase_cb hidl_status_cb) override;
+    Return<void> setCoexUnsafeChannels(
+        const hidl_vec<CoexUnsafeChannel>& unsafe_channels,
+        hidl_bitfield<IfaceType> restrictions,
+        setCoexUnsafeChannels_cb hidl_status_cb) override;
 
    private:
     void invalidateAndRemoveAllIfaces();
@@ -252,6 +256,8 @@
         const sp<V1_4::IWifiChipEventCallback>& event_callback);
     WifiStatus setMultiStaPrimaryConnectionInternal(const std::string& ifname);
     WifiStatus setMultiStaUseCaseInternal(MultiStaUseCase use_case);
+    WifiStatus setCoexUnsafeChannelsInternal(
+        std::vector<CoexUnsafeChannel> unsafe_channels, uint32_t restrictions);
 
     WifiStatus handleChipConfiguration(
         std::unique_lock<std::recursive_mutex>* lock, ChipModeId mode_id);
diff --git a/wifi/1.5/default/wifi_legacy_hal.cpp b/wifi/1.5/default/wifi_legacy_hal.cpp
index 76e718b..773dd9b 100644
--- a/wifi/1.5/default/wifi_legacy_hal.cpp
+++ b/wifi/1.5/default/wifi_legacy_hal.cpp
@@ -1521,6 +1521,14 @@
                                                           use_case);
 }
 
+wifi_error WifiLegacyHal::setCoexUnsafeChannels(
+    std::vector<wifi_coex_unsafe_channel> unsafe_channels,
+    uint32_t restrictions) {
+    return global_func_table_.wifi_set_coex_unsafe_channels(
+        global_handle_, unsafe_channels.size(), unsafe_channels.data(),
+        restrictions);
+}
+
 void WifiLegacyHal::invalidate() {
     global_handle_ = nullptr;
     iface_name_to_handle_.clear();
diff --git a/wifi/1.5/default/wifi_legacy_hal.h b/wifi/1.5/default/wifi_legacy_hal.h
index 555c540..6266cf6 100644
--- a/wifi/1.5/default/wifi_legacy_hal.h
+++ b/wifi/1.5/default/wifi_legacy_hal.h
@@ -386,6 +386,11 @@
     virtual wifi_error multiStaSetPrimaryConnection(const std::string& ifname);
     virtual wifi_error multiStaSetUseCase(wifi_multi_sta_use_case use_case);
 
+    // Coex functions.
+    virtual wifi_error setCoexUnsafeChannels(
+        std::vector<wifi_coex_unsafe_channel> unsafe_channels,
+        uint32_t restrictions);
+
    private:
     // Retrieve interface handles for all the available interfaces.
     wifi_error retrieveIfaceHandles();
diff --git a/wifi/1.5/default/wifi_legacy_hal_stubs.cpp b/wifi/1.5/default/wifi_legacy_hal_stubs.cpp
index 71d2ddf..b6c908b 100644
--- a/wifi/1.5/default/wifi_legacy_hal_stubs.cpp
+++ b/wifi/1.5/default/wifi_legacy_hal_stubs.cpp
@@ -149,6 +149,7 @@
     populateStubFor(&hal_fn->wifi_get_chip_feature_set);
     populateStubFor(&hal_fn->wifi_multi_sta_set_primary_connection);
     populateStubFor(&hal_fn->wifi_multi_sta_set_use_case);
+    populateStubFor(&hal_fn->wifi_set_coex_unsafe_channels);
 
     return true;
 }
diff --git a/wifi/hostapd/1.3/IHostapd.hal b/wifi/hostapd/1.3/IHostapd.hal
index be6fe59..70de7c2 100644
--- a/wifi/hostapd/1.3/IHostapd.hal
+++ b/wifi/hostapd/1.3/IHostapd.hal
@@ -17,6 +17,8 @@
 package android.hardware.wifi.hostapd@1.3;
 
 import @1.2::HostapdStatus;
+import @1.2::IHostapd.BandMask;
+import @1.2::IHostapd.HwModeParams;
 import @1.2::IHostapd.IfaceParams;
 import @1.2::IHostapd.NetworkParams;
 import @1.2::IHostapd;
@@ -27,6 +29,28 @@
  */
 interface IHostapd extends @1.2::IHostapd {
 
+    enum BandMask : @1.2::IHostapd.BandMask {
+        /**
+         * 60 GHz band.
+         */
+        BAND_60_GHZ = 1 << 3,
+    };
+
+    /**
+     * Parameters to control the HW mode for the interface.
+     */
+    struct HwModeParams {
+        /**
+         * Baseline information as defined in HAL 1.2.
+         */
+        @1.2::IHostapd.HwModeParams V1_2;
+
+        /**
+         * Enable EDMG (802.11ay), this option is only allowed for the 60GHz band.
+         */
+        bool enableEdmg;
+    };
+
     /**
      * Parameters to control the channel selection for the interface.
      */
@@ -52,10 +76,20 @@
          * Channel number (IEEE 802.11) to use for the interface.
          * If ACS is enabled, this field is ignored.
          *
+         * If |enableEdmg| is true, the channel must be set. Refer to
+         * P802.11ay_D4.0 29.3.4.
+         *
          * Note: It is used instead of V1_0::ChannelParams.channel inside
          * V1_3::IfaceParams.V1_2.V1_1.V1_0.
          */
         uint32_t channel;
+
+        /**
+         * Band to use for the SoftAp operations.
+         * Note: It is used instead of V1_2::ChannelParams.bandMask inside
+         * V1_3::IfaceParams.V1_2.channelParams
+         */
+        bitfield<BandMask> bandMask;
     };
 
     /**
@@ -68,6 +102,11 @@
         @1.2::IHostapd.IfaceParams V1_2;
 
         /**
+         * Additional Hw mode params for the interface
+         */
+        HwModeParams hwModeParams;
+
+        /**
          * The list of the channel params for the dual interfaces.
          */
         vec<ChannelParams> channelParamsList;
diff --git a/wifi/hostapd/1.3/types.hal b/wifi/hostapd/1.3/types.hal
index de85043..f453df7 100644
--- a/wifi/hostapd/1.3/types.hal
+++ b/wifi/hostapd/1.3/types.hal
@@ -26,6 +26,7 @@
  *                     [hw_mode is HOSTAPD_MODE_IEEE80211A and VHT is 0].
  * WIFI_STANDARD_11AC = hw_mode is HOSTAPD_MODE_IEEE80211A and VHT is 1.
  * WIFI_STANDARD_11AX = hw_mode is HOSTAPD_MODE_IEEE80211AX.
+ * WIFI_STANDARD_11AD = hw_mode is HOSTAPD_MODE_IEEE80211AD.
  */
 enum Generation : uint32_t {
     WIFI_STANDARD_UNKNOWN = -1,
@@ -33,6 +34,7 @@
     WIFI_STANDARD_11N = 1,
     WIFI_STANDARD_11AC = 2,
     WIFI_STANDARD_11AX = 3,
+    WIFI_STANDARD_11AD = 4,
 };
 
 /**
@@ -46,4 +48,8 @@
     WIFI_BANDWIDTH_80 = 4,
     WIFI_BANDWIDTH_80P80 = 5,
     WIFI_BANDWIDTH_160 = 6,
+    WIFI_BANDWIDTH_2160 = 7,
+    WIFI_BANDWIDTH_4320 = 8,
+    WIFI_BANDWIDTH_6480 = 9,
+    WIFI_BANDWIDTH_8640 = 10,
 };