Merge "Add Thread network HAL"
diff --git a/automotive/audiocontrol/aidl/aidl_api/android.hardware.automotive.audiocontrol/current/android/hardware/automotive/audiocontrol/IAudioControl.aidl b/automotive/audiocontrol/aidl/aidl_api/android.hardware.automotive.audiocontrol/current/android/hardware/automotive/audiocontrol/IAudioControl.aidl
index 8dc5ffe..ffd575d 100644
--- a/automotive/audiocontrol/aidl/aidl_api/android.hardware.automotive.audiocontrol/current/android/hardware/automotive/audiocontrol/IAudioControl.aidl
+++ b/automotive/audiocontrol/aidl/aidl_api/android.hardware.automotive.audiocontrol/current/android/hardware/automotive/audiocontrol/IAudioControl.aidl
@@ -46,4 +46,6 @@
   oneway void onAudioFocusChangeWithMetaData(in android.hardware.audio.common.PlaybackTrackMetadata playbackMetaData, in int zoneId, in android.hardware.automotive.audiocontrol.AudioFocusChange focusChange);
   oneway void setAudioDeviceGainsChanged(in android.hardware.automotive.audiocontrol.Reasons[] reasons, in android.hardware.automotive.audiocontrol.AudioGainConfigInfo[] gains);
   oneway void registerGainCallback(in android.hardware.automotive.audiocontrol.IAudioGainCallback callback);
+  void setModuleChangeCallback(in android.hardware.automotive.audiocontrol.IModuleChangeCallback callback);
+  void clearModuleChangeCallback();
 }
diff --git a/automotive/audiocontrol/aidl/aidl_api/android.hardware.automotive.audiocontrol/current/android/hardware/automotive/audiocontrol/IModuleChangeCallback.aidl b/automotive/audiocontrol/aidl/aidl_api/android.hardware.automotive.audiocontrol/current/android/hardware/automotive/audiocontrol/IModuleChangeCallback.aidl
new file mode 100644
index 0000000..2bbb936
--- /dev/null
+++ b/automotive/audiocontrol/aidl/aidl_api/android.hardware.automotive.audiocontrol/current/android/hardware/automotive/audiocontrol/IModuleChangeCallback.aidl
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2023 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.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE.                          //
+///////////////////////////////////////////////////////////////////////////////
+
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+//     the interface (from the latest frozen version), the build system will
+//     prompt you to update this file with `m <name>-update-api`.
+//
+// You must not make a backward incompatible change to any AIDL file 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.automotive.audiocontrol;
+@VintfStability
+interface IModuleChangeCallback {
+  oneway void onAudioPortsChanged(in android.media.audio.common.AudioPort[] audioPorts);
+}
diff --git a/automotive/audiocontrol/aidl/android/hardware/automotive/audiocontrol/IAudioControl.aidl b/automotive/audiocontrol/aidl/android/hardware/automotive/audiocontrol/IAudioControl.aidl
index 0ffcd5e..9564efc 100644
--- a/automotive/audiocontrol/aidl/android/hardware/automotive/audiocontrol/IAudioControl.aidl
+++ b/automotive/audiocontrol/aidl/android/hardware/automotive/audiocontrol/IAudioControl.aidl
@@ -51,6 +51,7 @@
 import android.hardware.automotive.audiocontrol.DuckingInfo;
 import android.hardware.automotive.audiocontrol.IAudioGainCallback;
 import android.hardware.automotive.audiocontrol.IFocusListener;
+import android.hardware.automotive.audiocontrol.IModuleChangeCallback;
 import android.hardware.automotive.audiocontrol.MutingInfo;
 import android.hardware.automotive.audiocontrol.Reasons;
 
@@ -183,4 +184,26 @@
      *                 interface.
      */
     oneway void registerGainCallback(in IAudioGainCallback callback);
+
+    /**
+     * Sets callback with HAL for notifying changes to hardware module (that is:
+     * {@link android.hardware.audio.core.IModule}) configurations.
+     *
+     * @param callback The {@link android.hardware.automotive.audiocontrol.IModuleChangeCallback}
+     *                 interface to use use when new updates are available for
+     *                 {@link android.hardware.audio.core.IModule} configs
+     * @throws EX_UNSUPPORTED_OPERATION if dynamic audio configs are not supported.
+     * @throws EX_ILLEGAL_STATE if a callback already exists
+     * @throws EX_ILLEGAL_ARGUMENT if the passed callback is (@code null}
+     */
+    void setModuleChangeCallback(in IModuleChangeCallback callback);
+
+    /**
+     * Clears module change callback
+     *
+     * If no callback is registered previously, then this call should be a no-op.
+     *
+     * @throws EX_UNSUPPORTED_OPERATION if dynamic audio configs are not supported.
+     */
+    void clearModuleChangeCallback();
 }
diff --git a/automotive/audiocontrol/aidl/android/hardware/automotive/audiocontrol/IModuleChangeCallback.aidl b/automotive/audiocontrol/aidl/android/hardware/automotive/audiocontrol/IModuleChangeCallback.aidl
new file mode 100644
index 0000000..4282483
--- /dev/null
+++ b/automotive/audiocontrol/aidl/android/hardware/automotive/audiocontrol/IModuleChangeCallback.aidl
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2023 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.automotive.audiocontrol;
+
+import android.media.audio.common.AudioPort;
+
+/**
+ * Interface definition for asynchronous changes to audio configs defined
+ * for a hardware {@link android.hardware.audio.core.IModule}.
+ */
+@VintfStability
+oneway interface IModuleChangeCallback {
+    /**
+     * Used to indicate that one or more {@link android.media.audio.common.AudioPort}
+     * configs have changed. Implementations MUST return at least one AudioPort.
+     *
+     * Notes for AudioPort:
+     * 1. For V3, the support will be limited to configurable AudioGain stages - per
+     *    car audio framework support.
+     * 2. For automotive 'bus' devices, the expected settings are
+     *     AudioDevice {
+     *        AudioDeviceDescription {type: IN/OUT_DEVICE, connection: CONNECTION_BUS}
+     *        AudioDeviceAddress {id: string}}
+     *
+     * Notes for AudioGain:
+     * 1. Car audio framework only supports AudioGainMode::JOINT. Any other mode
+     *    selection will be ignored.
+     *    See {@link android.media.audio.common.AudioGainMode}
+     * 2. Implementations MUST ensure that the gain stages are identical for buses
+     *    that map to the same volume group. Any inconsistencies will result in
+     *    inferior volume-change experience to the users.
+     * 3. Implementations MUST ensure that the new gain stages are subset (do not
+     *    exceed) of the gain stage definitions provided to audio policy. If they
+     *    exceed, it can result in failure when setting value over the range
+     *    allowed by the audio policy.
+     *
+     * Other notes:
+     * 1. In case of AudioControl  service restart or resume, the implementations MUST
+     *    issue an immediate callback following registration.
+     * 2. In case of client restart, the AudioControl service MUST clear all stale
+     *    callbacks.
+     *
+     * @param audioPorts list of {@link android.media.audio.common.AudioPort} that
+     *                   are updated
+     */
+    void onAudioPortsChanged(in AudioPort[] audioPorts);
+}
diff --git a/automotive/audiocontrol/aidl/default/Android.bp b/automotive/audiocontrol/aidl/default/Android.bp
index 6bf4b9d..dde05c3 100644
--- a/automotive/audiocontrol/aidl/default/Android.bp
+++ b/automotive/audiocontrol/aidl/default/Android.bp
@@ -31,7 +31,7 @@
         "android.hardware.audio.common@7.0-enums",
         "android.hardware.audio.common-V1-ndk",
         "android.frameworks.automotive.powerpolicy-V1-ndk",
-        "android.hardware.automotive.audiocontrol-V2-ndk",
+        "android.hardware.automotive.audiocontrol-V3-ndk",
         "libbase",
         "libbinder_ndk",
         "libcutils",
diff --git a/automotive/audiocontrol/aidl/default/AudioControl.cpp b/automotive/audiocontrol/aidl/default/AudioControl.cpp
index a121f8b..cf7307d 100644
--- a/automotive/audiocontrol/aidl/default/AudioControl.cpp
+++ b/automotive/audiocontrol/aidl/default/AudioControl.cpp
@@ -24,6 +24,7 @@
 #include <aidl/android/hardware/automotive/audiocontrol/IFocusListener.h>
 
 #include <android-base/logging.h>
+#include <android-base/parsebool.h>
 #include <android-base/parseint.h>
 #include <android-base/strings.h>
 
@@ -37,6 +38,8 @@
 namespace aidl::android::hardware::automotive::audiocontrol {
 
 using ::android::base::EqualsIgnoreCase;
+using ::android::base::ParseBool;
+using ::android::base::ParseBoolResult;
 using ::android::base::ParseInt;
 using ::std::shared_ptr;
 using ::std::string;
@@ -70,6 +73,95 @@
 }
 }  // namespace
 
+namespace {
+using ::aidl::android::media::audio::common::AudioChannelLayout;
+using ::aidl::android::media::audio::common::AudioDeviceDescription;
+using ::aidl::android::media::audio::common::AudioDeviceType;
+using ::aidl::android::media::audio::common::AudioFormatDescription;
+using ::aidl::android::media::audio::common::AudioFormatType;
+using ::aidl::android::media::audio::common::AudioGain;
+using ::aidl::android::media::audio::common::AudioGainMode;
+using ::aidl::android::media::audio::common::AudioIoFlags;
+using ::aidl::android::media::audio::common::AudioOutputFlags;
+using ::aidl::android::media::audio::common::AudioPort;
+using ::aidl::android::media::audio::common::AudioPortDeviceExt;
+using ::aidl::android::media::audio::common::AudioPortExt;
+using ::aidl::android::media::audio::common::AudioPortMixExt;
+using ::aidl::android::media::audio::common::AudioProfile;
+using ::aidl::android::media::audio::common::PcmType;
+
+// reuse common code artifacts
+void fillProfile(const std::vector<int32_t>& channelLayouts,
+                 const std::vector<int32_t>& sampleRates, AudioProfile* profile) {
+    for (auto layout : channelLayouts) {
+        profile->channelMasks.push_back(
+                AudioChannelLayout::make<AudioChannelLayout::layoutMask>(layout));
+    }
+    profile->sampleRates.insert(profile->sampleRates.end(), sampleRates.begin(), sampleRates.end());
+}
+
+AudioProfile createProfile(PcmType pcmType, const std::vector<int32_t>& channelLayouts,
+                           const std::vector<int32_t>& sampleRates) {
+    AudioProfile profile;
+    profile.format.type = AudioFormatType::PCM;
+    profile.format.pcm = pcmType;
+    fillProfile(channelLayouts, sampleRates, &profile);
+    return profile;
+}
+
+AudioProfile createProfile(const std::string& encodingType,
+                           const std::vector<int32_t>& channelLayouts,
+                           const std::vector<int32_t>& sampleRates) {
+    AudioProfile profile;
+    profile.format.encoding = encodingType;
+    fillProfile(channelLayouts, sampleRates, &profile);
+    return profile;
+}
+
+AudioPortExt createDeviceExt(AudioDeviceType devType, int32_t flags,
+                             const std::string& connection = "", const std::string& address = "") {
+    AudioPortDeviceExt deviceExt;
+    deviceExt.device.type.type = devType;
+    if (devType == AudioDeviceType::IN_MICROPHONE && connection.empty()) {
+        deviceExt.device.address = "bottom";
+    } else if (devType == AudioDeviceType::IN_MICROPHONE_BACK && connection.empty()) {
+        deviceExt.device.address = "back";
+    } else {
+        deviceExt.device.address = std::move(address);
+    }
+    deviceExt.device.type.connection = std::move(connection);
+    deviceExt.flags = flags;
+    return AudioPortExt::make<AudioPortExt::Tag::device>(deviceExt);
+}
+
+AudioPort createPort(int32_t id, const std::string& name, int32_t flags, bool isInput,
+                     const AudioPortExt& ext) {
+    AudioPort port;
+    port.id = id;
+    port.name = name;
+    port.flags = isInput ? AudioIoFlags::make<AudioIoFlags::Tag::input>(flags)
+                         : AudioIoFlags::make<AudioIoFlags::Tag::output>(flags);
+    port.ext = ext;
+    return port;
+}
+
+AudioGain createGain(int32_t mode, AudioChannelLayout channelMask, int32_t minValue,
+                     int32_t maxValue, int32_t defaultValue, int32_t stepValue,
+                     int32_t minRampMs = 100, int32_t maxRampMs = 100, bool useForVolume = true) {
+    AudioGain gain;
+    gain.mode = mode;
+    gain.channelMask = channelMask;
+    gain.minValue = minValue;
+    gain.maxValue = maxValue;
+    gain.defaultValue = defaultValue;
+    gain.stepValue = stepValue;
+    gain.minRampMs = minRampMs;
+    gain.maxRampMs = maxRampMs;
+    gain.useForVolume = useForVolume;
+    return gain;
+}
+}  // namespace
+
 ndk::ScopedAStatus AudioControl::registerFocusListener(
         const shared_ptr<IFocusListener>& in_listener) {
     LOG(DEBUG) << "registering focus listener";
@@ -190,6 +282,33 @@
     return ndk::ScopedAStatus::ok();
 }
 
+ndk::ScopedAStatus AudioControl::setModuleChangeCallback(
+        const std::shared_ptr<IModuleChangeCallback>& in_callback) {
+    LOG(DEBUG) << ": " << __func__;
+
+    if (in_callback.get() == nullptr) {
+        LOG(ERROR) << __func__ << ": Callback is nullptr";
+        return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
+    }
+    if (mModuleChangeCallback != nullptr) {
+        LOG(ERROR) << __func__ << ": Module change callback was already registered";
+        return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE);
+    }
+    std::atomic_store(&mModuleChangeCallback, in_callback);
+    return ndk::ScopedAStatus::ok();
+}
+
+ndk::ScopedAStatus AudioControl::clearModuleChangeCallback() {
+    if (mModuleChangeCallback != nullptr) {
+        shared_ptr<IModuleChangeCallback> nullCallback = nullptr;
+        std::atomic_store(&mModuleChangeCallback, nullCallback);
+        LOG(DEBUG) << ":" << __func__ << ": Unregistered successfully";
+    } else {
+        LOG(DEBUG) << ":" << __func__ << ": No callback registered, no-op";
+    }
+    return ndk::ScopedAStatus::ok();
+}
+
 binder_status_t AudioControl::dump(int fd, const char** args, uint32_t numArgs) {
     if (numArgs == 0) {
         return dumpsys(fd);
@@ -208,6 +327,8 @@
         return cmdAbandonFocusWithMetaData(fd, args, numArgs);
     } else if (EqualsIgnoreCase(option, "--audioGainCallback")) {
         return cmdOnAudioDeviceGainsChanged(fd, args, numArgs);
+    } else if (EqualsIgnoreCase(option, "--audioPortsChangedCallback")) {
+        return cmdOnAudioPortsChanged(fd, args, numArgs);
     } else {
         dprintf(fd, "Invalid option: %s\n", option.c_str());
         return STATUS_BAD_VALUE;
@@ -262,7 +383,21 @@
     dprintf(fd,
             "Tags are optional. If provided, it must follow the <key>=<value> pattern, where the "
             "value is namespaced (for example com.google.strategy=VR).\n");
-
+    dprintf(fd,
+            "--audioPortsChangedCallback <ID_1> <NAME_1> <BUS_ADDRESS_1> <CONNECTION_TYPE_1> "
+            "<AUDIO_GAINS_1> [<ID_N> <NAME_N> <BUS_ADDRESS_N> <CONNECTION_TYPE_N> "
+            "<AUDIO_GAINS_N>]: fires audio ports changed callback. Carries list of modified "
+            "AudioPorts. "
+            "For simplicity, this command accepts limited information for each AudioPort: "
+            "id(int), name(string), port address(string), connection type (string), "
+            "audio gain (csv int)\n");
+    dprintf(fd, "Notes: \n");
+    dprintf(fd,
+            "1. AudioGain csv should match definition at "
+            "android/media/audio/common/AudioPort.aidl\n");
+    dprintf(fd,
+            "2. See android/media/audio/common/AudioDeviceDescription.aidl for valid "
+            "<CONNECTION_TYPE> values.\n");
     return STATUS_OK;
 }
 
@@ -514,4 +649,166 @@
             toEnumString(reasons).c_str(), toString(agcis).c_str());
     return STATUS_OK;
 }
+
+binder_status_t AudioControl::parseAudioGains(int fd, const std::string& stringGain,
+                                              std::vector<AudioGain>& gains) {
+    const int kAudioGainSize = 9;
+    std::stringstream csvGain(stringGain);
+    std::vector<std::string> vecGain;
+    std::string value;
+    while (getline(csvGain, value, ',')) {
+        vecGain.push_back(value);
+    }
+
+    if ((vecGain.size() == 0) || ((vecGain.size() % kAudioGainSize) != 0)) {
+        dprintf(fd, "Erroneous input to generate AudioGain: %s\n", stringGain.c_str());
+        return STATUS_BAD_VALUE;
+    }
+
+    // iterate over injected AudioGains
+    for (int index = 0; index < vecGain.size(); index += kAudioGainSize) {
+        int32_t mode;
+        if (!safelyParseInt(vecGain[index], &mode)) {
+            dprintf(fd, "Non-integer index provided with request: %s\n", vecGain[index].c_str());
+            return STATUS_BAD_VALUE;
+        }
+
+        // car audio framework only supports JOINT mode.
+        // skip injected AudioGains that are not compliant with this.
+        if (mode != static_cast<int>(AudioGainMode::JOINT)) {
+            LOG(WARNING) << ":" << __func__ << ": skipping gain since it is not JOINT mode!";
+            continue;
+        }
+
+        int32_t layout;
+        if (!safelyParseInt(vecGain[index + 1], &layout)) {
+            dprintf(fd, "Non-integer index provided with request: %s\n",
+                    vecGain[index + 1].c_str());
+            return STATUS_BAD_VALUE;
+        }
+        AudioChannelLayout channelMask =
+                AudioChannelLayout::make<AudioChannelLayout::layoutMask>(layout);
+
+        int32_t minValue;
+        if (!safelyParseInt(vecGain[index + 2], &minValue)) {
+            dprintf(fd, "Non-integer index provided with request: %s\n",
+                    vecGain[index + 2].c_str());
+            return STATUS_BAD_VALUE;
+        }
+
+        int32_t maxValue;
+        if (!safelyParseInt(vecGain[index + 3], &maxValue)) {
+            dprintf(fd, "Non-integer index provided with request: %s\n",
+                    vecGain[index + 3].c_str());
+            return STATUS_BAD_VALUE;
+        }
+
+        int32_t defaultValue;
+        if (!safelyParseInt(vecGain[index + 4], &defaultValue)) {
+            dprintf(fd, "Non-integer index provided with request: %s\n",
+                    vecGain[index + 4].c_str());
+            return STATUS_BAD_VALUE;
+        }
+
+        int32_t stepValue;
+        if (!safelyParseInt(vecGain[index + 5], &stepValue)) {
+            dprintf(fd, "Non-integer index provided with request: %s\n",
+                    vecGain[index + 5].c_str());
+            return STATUS_BAD_VALUE;
+        }
+
+        int32_t minRampMs;
+        if (!safelyParseInt(vecGain[index + 6], &minRampMs)) {
+            dprintf(fd, "Non-integer index provided with request: %s\n",
+                    vecGain[index + 6].c_str());
+            return STATUS_BAD_VALUE;
+        }
+
+        int32_t maxRampMs;
+        if (!safelyParseInt(vecGain[index + 7], &maxRampMs)) {
+            dprintf(fd, "Non-integer index provided with request: %s\n",
+                    vecGain[index + 7].c_str());
+            return STATUS_BAD_VALUE;
+        }
+
+        ParseBoolResult useForVolume = ParseBool(vecGain[index + 8]);
+        if (useForVolume == ParseBoolResult::kError) {
+            dprintf(fd, "Non-boolean index provided with request: %s\n",
+                    vecGain[index + 8].c_str());
+            return STATUS_BAD_VALUE;
+        } else if (useForVolume == ParseBoolResult::kFalse) {
+            // at this level we only care about gain stages that are relevant
+            // for volume control. skip the gain stage if its flagged as false.
+            LOG(WARNING) << ":" << __func__
+                         << ": skipping gain since it is not for volume control!";
+            continue;
+        }
+
+        AudioGain gain = createGain(mode, channelMask, minValue, maxValue, defaultValue, stepValue,
+                                    minRampMs, maxRampMs, true /*useForVolume*/);
+        gains.push_back(gain);
+    }
+    return STATUS_OK;
+}
+
+binder_status_t AudioControl::cmdOnAudioPortsChanged(int fd, const char** args, uint32_t numArgs) {
+    if (!checkCallerHasWritePermissions(fd)) {
+        return STATUS_PERMISSION_DENIED;
+    }
+
+    if ((numArgs < 6) || ((numArgs - 1) % 5 != 0)) {
+        dprintf(fd,
+                "Invalid number of arguments: please provide\n"
+                "--audioPortsChangedCallback <ID_1> <NAME_1> <BUS_ADDRESS_1> <CONNECTION_TYPE_1> "
+                "<AUDIO_GAINS_1> [<ID_N> <NAME_N> <BUS_ADDRESS_N> <CONNECTION_TYPE_N> "
+                "<AUDIO_GAINS_N>]: triggers audio ports changed callback. Carries list of "
+                "modified AudioPorts. "
+                "For simplicity, this command accepts limited information for each AudioPort: "
+                "id(int), name(string), port address(string), connection type (string), "
+                "audio gain (csv int)\n");
+        return STATUS_BAD_VALUE;
+    }
+
+    std::vector<AudioPort> ports;
+    for (uint32_t i = 1; i < numArgs; i += 5) {
+        binder_status_t status;
+        int32_t id;
+        if (!safelyParseInt(std::string(args[i]), &id)) {
+            dprintf(fd, "Non-integer index provided with request: %s\n",
+                    std::string(args[i]).c_str());
+            return STATUS_BAD_VALUE;
+        }
+
+        std::string name = std::string(args[i + 1]);
+        std::string address = std::string(args[i + 2]);
+        std::string connection = std::string(args[i + 3]);
+
+        std::string stringGains = std::string(args[i + 4]);
+        std::vector<AudioGain> gains;
+        status = parseAudioGains(fd, stringGains, gains);
+        if (status != STATUS_OK) {
+            return status;
+        }
+
+        AudioPort port = createPort(
+                id, name, 0 /*flags*/, false /*isInput*/,
+                createDeviceExt(AudioDeviceType::OUT_DEVICE, 0 /*flags*/, connection, address));
+        port.gains.insert(port.gains.begin(), gains.begin(), gains.end());
+
+        ports.push_back(port);
+    }
+
+    if (mModuleChangeCallback == nullptr) {
+        dprintf(fd,
+                "Unable to trigger audio port callback for ports: %s \n"
+                " - no module change callback registered\n",
+                toString(ports).c_str());
+        return STATUS_BAD_VALUE;
+    }
+
+    // TODO (b/269139706) fix atomic read issue
+    mModuleChangeCallback->onAudioPortsChanged(ports);
+    dprintf(fd, "SUCCESS audio port callback for ports: %s \n", toString(ports).c_str());
+    return STATUS_OK;
+}
 }  // namespace aidl::android::hardware::automotive::audiocontrol
diff --git a/automotive/audiocontrol/aidl/default/AudioControl.h b/automotive/audiocontrol/aidl/default/AudioControl.h
index 16b80e8..7eca446 100644
--- a/automotive/audiocontrol/aidl/default/AudioControl.h
+++ b/automotive/audiocontrol/aidl/default/AudioControl.h
@@ -21,11 +21,20 @@
 #include <aidl/android/hardware/automotive/audiocontrol/BnAudioControl.h>
 #include <aidl/android/hardware/automotive/audiocontrol/DuckingInfo.h>
 #include <aidl/android/hardware/automotive/audiocontrol/IAudioGainCallback.h>
+#include <aidl/android/hardware/automotive/audiocontrol/IModuleChangeCallback.h>
 #include <aidl/android/hardware/automotive/audiocontrol/MutingInfo.h>
 #include <aidl/android/hardware/automotive/audiocontrol/Reasons.h>
 
 #include <aidl/android/hardware/audio/common/PlaybackTrackMetadata.h>
 
+#include <aidl/android/media/audio/common/AudioChannelLayout.h>
+#include <aidl/android/media/audio/common/AudioDeviceType.h>
+#include <aidl/android/media/audio/common/AudioFormatDescription.h>
+#include <aidl/android/media/audio/common/AudioFormatType.h>
+#include <aidl/android/media/audio/common/AudioGainMode.h>
+#include <aidl/android/media/audio/common/AudioIoFlags.h>
+#include <aidl/android/media/audio/common/AudioOutputFlags.h>
+
 namespace aidl::android::hardware::automotive::audiocontrol {
 
 namespace audiohalcommon = ::aidl::android::hardware::audio::common;
@@ -51,6 +60,9 @@
             const std::vector<AudioGainConfigInfo>& in_gains) override;
     ndk::ScopedAStatus registerGainCallback(
             const std::shared_ptr<IAudioGainCallback>& in_callback) override;
+    ndk::ScopedAStatus setModuleChangeCallback(
+            const std::shared_ptr<IModuleChangeCallback>& in_callback) override;
+    ndk::ScopedAStatus clearModuleChangeCallback() override;
 
     binder_status_t dump(int fd, const char** args, uint32_t numArgs) override;
 
@@ -67,15 +79,23 @@
      */
     std::shared_ptr<IAudioGainCallback> mAudioGainCallback = nullptr;
 
+    std::shared_ptr<IModuleChangeCallback> mModuleChangeCallback = nullptr;
+
     binder_status_t cmdHelp(int fd) const;
     binder_status_t cmdRequestFocus(int fd, const char** args, uint32_t numArgs);
     binder_status_t cmdAbandonFocus(int fd, const char** args, uint32_t numArgs);
     binder_status_t cmdRequestFocusWithMetaData(int fd, const char** args, uint32_t numArgs);
     binder_status_t cmdAbandonFocusWithMetaData(int fd, const char** args, uint32_t numArgs);
     binder_status_t cmdOnAudioDeviceGainsChanged(int fd, const char** args, uint32_t numArgs);
+    binder_status_t cmdOnAudioPortsChanged(int fd, const char** args, uint32_t numArgs);
 
     binder_status_t parseMetaData(int fd, const std::string& metadataLiteral,
                                   audiohalcommon::PlaybackTrackMetadata& trackMetadata);
+    binder_status_t parseAudioGains(
+            int fd, const std::string& stringGain,
+            std::vector<::aidl::android::media::audio::common::AudioGain>& gains);
+    binder_status_t parseSampleRates(int fd, const std::string& sampleRates,
+                                     std::vector<int32_t>& vecSampleRates);
 
     binder_status_t dumpsys(int fd);
 };
diff --git a/automotive/audiocontrol/aidl/vts/Android.bp b/automotive/audiocontrol/aidl/vts/Android.bp
index edac160..a9122ce 100644
--- a/automotive/audiocontrol/aidl/vts/Android.bp
+++ b/automotive/audiocontrol/aidl/vts/Android.bp
@@ -39,7 +39,7 @@
         "libxml2",
     ],
     static_libs: [
-        "android.hardware.automotive.audiocontrol-V2-cpp",
+        "android.hardware.automotive.audiocontrol-V3-cpp",
         "libgmock",
     ],
     test_suites: [
diff --git a/automotive/audiocontrol/aidl/vts/VtsHalAudioControlTargetTest.cpp b/automotive/audiocontrol/aidl/vts/VtsHalAudioControlTargetTest.cpp
index f4f5eef..f4e3b5a 100644
--- a/automotive/audiocontrol/aidl/vts/VtsHalAudioControlTargetTest.cpp
+++ b/automotive/audiocontrol/aidl/vts/VtsHalAudioControlTargetTest.cpp
@@ -21,6 +21,7 @@
 
 #include <android/hardware/automotive/audiocontrol/BnAudioGainCallback.h>
 #include <android/hardware/automotive/audiocontrol/BnFocusListener.h>
+#include <android/hardware/automotive/audiocontrol/BnModuleChangeCallback.h>
 #include <android/hardware/automotive/audiocontrol/IAudioControl.h>
 #include <android/log.h>
 #include <binder/IServiceManager.h>
@@ -34,10 +35,14 @@
 using android::hardware::automotive::audiocontrol::AudioGainConfigInfo;
 using android::hardware::automotive::audiocontrol::BnAudioGainCallback;
 using android::hardware::automotive::audiocontrol::BnFocusListener;
+using android::hardware::automotive::audiocontrol::BnModuleChangeCallback;
 using android::hardware::automotive::audiocontrol::DuckingInfo;
 using android::hardware::automotive::audiocontrol::IAudioControl;
+using android::hardware::automotive::audiocontrol::IModuleChangeCallback;
 using android::hardware::automotive::audiocontrol::MutingInfo;
 using android::hardware::automotive::audiocontrol::Reasons;
+using ::testing::AnyOf;
+using ::testing::Eq;
 
 #include "android_audio_policy_configuration_V7_0.h"
 
@@ -55,6 +60,8 @@
         ASSERT_NE(audioControl, nullptr);
     }
 
+    void TearDown() override { audioControl = nullptr; }
+
     sp<IAudioControl> audioControl;
     int32_t capabilities;
 };
@@ -226,6 +233,47 @@
     ASSERT_TRUE(audioControl->registerGainCallback(gainCallback2).isOk());
 }
 
+/*
+ * Test Module change Callback registration.
+ *
+ * Verifies that:
+ * - setModuleChangeCallback succeeds
+ * - setting a double callback fails with exception
+ * - clearModuleChangeCallback succeeds
+ * - setting with nullptr callback fails with exception
+ * - closing handle does not crash
+ */
+struct ModuleChangeCallbackMock : BnModuleChangeCallback {
+    MOCK_METHOD(Status, onAudioPortsChanged,
+                (const std::vector<android::media::audio::common::AudioPort>& audioPorts));
+};
+
+TEST_P(AudioControlAidl, RegisterModuleChangeCallbackTwiceThrowsException) {
+    ALOGI("Register Module change callback test");
+    // make sure no stale callbacks.
+    audioControl->clearModuleChangeCallback();
+
+    sp<ModuleChangeCallbackMock> moduleChangeCallback = new ModuleChangeCallbackMock();
+    auto status = audioControl->setModuleChangeCallback(moduleChangeCallback);
+    EXPECT_THAT(status.exceptionCode(),
+                AnyOf(Eq(Status::EX_NONE), Eq(Status::EX_UNSUPPORTED_OPERATION)));
+    if (!status.isOk()) return;
+
+    sp<ModuleChangeCallbackMock> moduleChangeCallback2 = new ModuleChangeCallbackMock();
+    // no need to check for unsupported feature
+    EXPECT_EQ(Status::EX_ILLEGAL_STATE,
+              audioControl->setModuleChangeCallback(moduleChangeCallback2).exceptionCode());
+    ASSERT_TRUE(audioControl->clearModuleChangeCallback().isOk());
+    ASSERT_TRUE(audioControl->setModuleChangeCallback(moduleChangeCallback2).isOk());
+}
+
+TEST_P(AudioControlAidl, RegisterModuleChangeNullCallbackThrowsException) {
+    ALOGI("Register Module change callback with nullptr test");
+    auto status = audioControl->setModuleChangeCallback(nullptr);
+    EXPECT_THAT(status.exceptionCode(),
+                AnyOf(Eq(Status::EX_ILLEGAL_ARGUMENT), Eq(Status::EX_UNSUPPORTED_OPERATION)));
+}
+
 GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(AudioControlAidl);
 INSTANTIATE_TEST_SUITE_P(
         Audiocontrol, AudioControlAidl,
diff --git a/automotive/vehicle/aidl_property/aidl_api/android.hardware.automotive.vehicle.property/current/android/hardware/automotive/vehicle/EvsServiceType.aidl b/automotive/vehicle/aidl_property/aidl_api/android.hardware.automotive.vehicle.property/current/android/hardware/automotive/vehicle/EvsServiceType.aidl
index 1363a64..285732c 100644
--- a/automotive/vehicle/aidl_property/aidl_api/android.hardware.automotive.vehicle.property/current/android/hardware/automotive/vehicle/EvsServiceType.aidl
+++ b/automotive/vehicle/aidl_property/aidl_api/android.hardware.automotive.vehicle.property/current/android/hardware/automotive/vehicle/EvsServiceType.aidl
@@ -36,4 +36,11 @@
 enum EvsServiceType {
   REARVIEW = 0,
   SURROUNDVIEW = 1,
+  FRONTVIEW = 2,
+  LEFTVIEW = 3,
+  RIGHTVIEW = 4,
+  DRIVERVIEW = 5,
+  FRONTPASSENGERSVIEW = 6,
+  REARPASSENGERSVIEW = 7,
+  USER_DEFINED = 1000,
 }
diff --git a/automotive/vehicle/aidl_property/android/hardware/automotive/vehicle/EvsServiceType.aidl b/automotive/vehicle/aidl_property/android/hardware/automotive/vehicle/EvsServiceType.aidl
index 6c621f7..20582dc 100644
--- a/automotive/vehicle/aidl_property/android/hardware/automotive/vehicle/EvsServiceType.aidl
+++ b/automotive/vehicle/aidl_property/android/hardware/automotive/vehicle/EvsServiceType.aidl
@@ -24,4 +24,11 @@
 enum EvsServiceType {
     REARVIEW = 0,
     SURROUNDVIEW = 1,
+    FRONTVIEW = 2,
+    LEFTVIEW = 3,
+    RIGHTVIEW = 4,
+    DRIVERVIEW = 5,
+    FRONTPASSENGERSVIEW = 6,
+    REARPASSENGERSVIEW = 7,
+    USER_DEFINED = 1000,
 }
diff --git a/biometrics/fingerprint/aidl/default/fingerprint-example.rc b/biometrics/fingerprint/aidl/default/fingerprint-example.rc
index 10db00d..ee4713c 100644
--- a/biometrics/fingerprint/aidl/default/fingerprint-example.rc
+++ b/biometrics/fingerprint/aidl/default/fingerprint-example.rc
@@ -2,8 +2,6 @@
     class hal
     user nobody
     group nobody
+    interface aidl android.hardware.biometrics.fingerprint.IFingerprint/virtual
+    oneshot
     disabled
-on property:ro.vendor.fingerprint_virtual_hal_start=true
-    enable vendor.fingerprint-example
-on property:persist.vendor.fingerprint.virtual.type=*
-    enable vendor.fingerprint-example
diff --git a/biometrics/fingerprint/aidl/default/main.cpp b/biometrics/fingerprint/aidl/default/main.cpp
index 0e672b1..7df015b 100644
--- a/biometrics/fingerprint/aidl/default/main.cpp
+++ b/biometrics/fingerprint/aidl/default/main.cpp
@@ -28,8 +28,10 @@
     std::shared_ptr<Fingerprint> hal = ndk::SharedRefBase::make<Fingerprint>();
 
     const std::string instance = std::string(Fingerprint::descriptor) + "/virtual";
-    binder_status_t status = AServiceManager_addService(hal->asBinder().get(), instance.c_str());
+    binder_status_t status =
+            AServiceManager_registerLazyService(hal->asBinder().get(), instance.c_str());
     CHECK_EQ(status, STATUS_OK);
+    AServiceManager_forceLazyServicesPersist(true);
 
     ABinderProcess_joinThreadPool();
     return EXIT_FAILURE;  // should not reach
diff --git a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/LatencyMode.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/LatencyMode.aidl
index 5583679..1140f9e 100644
--- a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/LatencyMode.aidl
+++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/LatencyMode.aidl
@@ -34,7 +34,9 @@
 package android.hardware.bluetooth.audio;
 @Backing(type="int") @VintfStability
 enum LatencyMode {
-  UNKNOWN = 0,
-  LOW_LATENCY = 1,
-  FREE = 2,
+  UNKNOWN,
+  LOW_LATENCY,
+  FREE,
+  DYNAMIC_SPATIAL_AUDIO_SOFTWARE,
+  DYNAMIC_SPATIAL_AUDIO_HARDWARE,
 }
diff --git a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/LeAudioConfiguration.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/LeAudioConfiguration.aidl
index edb6795..679655c 100644
--- a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/LeAudioConfiguration.aidl
+++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/LeAudioConfiguration.aidl
@@ -42,5 +42,6 @@
   parcelable StreamMap {
     char streamHandle;
     int audioChannelAllocation;
+    boolean isStreamActive;
   }
 }
diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/LatencyMode.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/LatencyMode.aidl
index 0c354f7..ec181c1 100644
--- a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/LatencyMode.aidl
+++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/LatencyMode.aidl
@@ -22,4 +22,6 @@
     UNKNOWN,
     LOW_LATENCY,
     FREE,
+    DYNAMIC_SPATIAL_AUDIO_SOFTWARE,
+    DYNAMIC_SPATIAL_AUDIO_HARDWARE
 }
diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/LeAudioConfiguration.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/LeAudioConfiguration.aidl
index 0d1e3de..f22f309 100644
--- a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/LeAudioConfiguration.aidl
+++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/LeAudioConfiguration.aidl
@@ -35,6 +35,10 @@
          * Audio Location assigned number.
          */
         int audioChannelAllocation;
+        /*
+         * The stream handle status
+         */
+        boolean isStreamActive;
     }
     CodecType codecType;
     StreamMap[] streamMap;
diff --git a/compatibility_matrices/compatibility_matrix.4.xml b/compatibility_matrices/compatibility_matrix.4.xml
index 8ef0b3a..c898aab 100644
--- a/compatibility_matrices/compatibility_matrix.4.xml
+++ b/compatibility_matrices/compatibility_matrix.4.xml
@@ -171,7 +171,7 @@
             <instance>default</instance>
         </interface>
     </hal>
-    <hal format="hidl" optional="false">
+    <hal format="hidl" optional="true">
         <name>android.hardware.gatekeeper</name>
         <version>1.0</version>
         <interface>
diff --git a/compatibility_matrices/compatibility_matrix.5.xml b/compatibility_matrices/compatibility_matrix.5.xml
index 12b85c7..c5a1dc2 100644
--- a/compatibility_matrices/compatibility_matrix.5.xml
+++ b/compatibility_matrices/compatibility_matrix.5.xml
@@ -192,7 +192,7 @@
             <instance>default</instance>
         </interface>
     </hal>
-    <hal format="hidl" optional="false">
+    <hal format="hidl" optional="true">
         <name>android.hardware.gatekeeper</name>
         <version>1.0</version>
         <interface>
diff --git a/compatibility_matrices/compatibility_matrix.6.xml b/compatibility_matrices/compatibility_matrix.6.xml
index e19d2dd..1c76ee6 100644
--- a/compatibility_matrices/compatibility_matrix.6.xml
+++ b/compatibility_matrices/compatibility_matrix.6.xml
@@ -215,7 +215,7 @@
             <instance>default</instance>
         </interface>
     </hal>
-    <hal format="hidl" optional="false">
+    <hal format="hidl" optional="true">
         <name>android.hardware.gatekeeper</name>
         <version>1.0</version>
         <interface>
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/Capability.aidl b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/Capability.aidl
index 6e844ef..f02f8aa 100644
--- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/Capability.aidl
+++ b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/Capability.aidl
@@ -44,4 +44,5 @@
   SKIP_VALIDATE = 4,
   BOOT_DISPLAY_CONFIG = 5,
   HDR_OUTPUT_CONVERSION_CONFIG = 6,
+  REFRESH_RATE_CHANGED_CALLBACK_DEBUG = 7,
 }
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/Composition.aidl b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/Composition.aidl
index d2d8f04..34d6822 100644
--- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/Composition.aidl
+++ b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/Composition.aidl
@@ -41,4 +41,5 @@
   CURSOR = 4,
   SIDEBAND = 5,
   DISPLAY_DECORATION = 6,
+  REFRESH_RATE_INDICATOR = 7,
 }
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/IComposerCallback.aidl b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/IComposerCallback.aidl
index 21620e7..2c08cbe 100644
--- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/IComposerCallback.aidl
+++ b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/IComposerCallback.aidl
@@ -40,4 +40,5 @@
   oneway void onVsync(long display, long timestamp, int vsyncPeriodNanos);
   oneway void onVsyncPeriodTimingChanged(long display, in android.hardware.graphics.composer3.VsyncPeriodChangeTimeline updatedTimeline);
   oneway void onVsyncIdle(long display);
+  oneway void onRefreshRateChangedDebug(in android.hardware.graphics.composer3.RefreshRateChangedDebugData data);
 }
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/IComposerClient.aidl b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/IComposerClient.aidl
index 10ce067..af82b83 100644
--- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/IComposerClient.aidl
+++ b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/IComposerClient.aidl
@@ -78,6 +78,7 @@
   android.hardware.graphics.composer3.OverlayProperties getOverlaySupport();
   android.hardware.graphics.common.HdrConversionCapability[] getHdrConversionCapabilities();
   void setHdrConversionStrategy(in android.hardware.graphics.common.HdrConversionStrategy conversionStrategy);
+  void setRefreshRateChangedCallbackDebugEnabled(long display, boolean enabled);
   const int EX_BAD_CONFIG = 1;
   const int EX_BAD_DISPLAY = 2;
   const int EX_BAD_LAYER = 3;
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/RefreshRateChangedDebugData.aidl b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/RefreshRateChangedDebugData.aidl
new file mode 100644
index 0000000..2b9801a
--- /dev/null
+++ b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/RefreshRateChangedDebugData.aidl
@@ -0,0 +1,39 @@
+/**
+ * Copyright 2023, 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.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE.                          //
+///////////////////////////////////////////////////////////////////////////////
+
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+//     the interface (from the latest frozen version), the build system will
+//     prompt you to update this file with `m <name>-update-api`.
+//
+// You must not make a backward incompatible change to any AIDL file 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.graphics.composer3;
+@VintfStability
+parcelable RefreshRateChangedDebugData {
+  long display;
+  int vsyncPeriodNanos;
+}
diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/Capability.aidl b/graphics/composer/aidl/android/hardware/graphics/composer3/Capability.aidl
index 509a8f4..4638610 100644
--- a/graphics/composer/aidl/android/hardware/graphics/composer3/Capability.aidl
+++ b/graphics/composer/aidl/android/hardware/graphics/composer3/Capability.aidl
@@ -75,4 +75,15 @@
      * @see IComposerClient.setHdrConversionStrategy
      */
     HDR_OUTPUT_CONVERSION_CONFIG = 6,
+
+    /**
+     * Specifies that the device supports the callback onRefreshRateChangedDebug
+     * to pass information about the refresh rate.
+     * The refresh rate from the callback is used to update the refresh rate
+     * overlay indicator.
+     *
+     * @see IComposerClient.setRefreshRateChangedCallbackDebugEnabled
+     * @see IComposerCallback.onRefreshRateChangedDebug
+     */
+    REFRESH_RATE_CHANGED_CALLBACK_DEBUG = 7,
 }
diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/Composition.aidl b/graphics/composer/aidl/android/hardware/graphics/composer3/Composition.aidl
index 82b218b..37912b0 100644
--- a/graphics/composer/aidl/android/hardware/graphics/composer3/Composition.aidl
+++ b/graphics/composer/aidl/android/hardware/graphics/composer3/Composition.aidl
@@ -86,4 +86,14 @@
      * to either DEVICE or CLIENT.
      */
     DISPLAY_DECORATION = 6,
+
+    /**
+     * This composition type is similar to DEVICE, with a single difference,
+     * that indicates to HWC that this layer update is not considered an activity
+     * of any sort. For example, If HWC maintains a timer for activity to switch
+     * the display mode from a power save mode, it should not reset that timer.
+     *
+     * Upon validateDisplay, the device may request a change from this type to CLIENT.
+     */
+    REFRESH_RATE_INDICATOR = 7,
 }
diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/IComposerCallback.aidl b/graphics/composer/aidl/android/hardware/graphics/composer3/IComposerCallback.aidl
index 67954d4..f4384b7 100644
--- a/graphics/composer/aidl/android/hardware/graphics/composer3/IComposerCallback.aidl
+++ b/graphics/composer/aidl/android/hardware/graphics/composer3/IComposerCallback.aidl
@@ -16,6 +16,7 @@
 
 package android.hardware.graphics.composer3;
 
+import android.hardware.graphics.composer3.RefreshRateChangedDebugData;
 import android.hardware.graphics.composer3.VsyncPeriodChangeTimeline;
 
 @VintfStability
@@ -96,4 +97,25 @@
      * @param display is the display whose vsync cadence changed due to panel idle mode.
      */
     oneway void onVsyncIdle(long display);
+
+    /**
+     * Notifies the client the vsyncPeriod of the display changed.
+     * Whether or not to call this callback is managed by
+     * IComposerClient.setRefreshRateChangedCallbackDebugEnabled
+     *
+     * Immediate callback is required after the setRefreshRateChangedCallbackDebugEnabled
+     * called.
+     * When the panel refresh rate changes, as a result of a setActiveConfig or
+     * setActiveConfigWithConstraints, this callback should be called with the new panel
+     * refresh rate. In addition, when the panel refresh rate is changed by other means,
+     * such as idleness or DOZE power state, this callback should be called as well.
+     *
+     * This callback is used for debug purposes, and not for scheduling frames,
+     * therefore synchronization is not required.
+     *
+     * @see IComposerClient.setRefreshRateChangedCallbackDebugEnabled
+     *
+     * @param data is the data for the callback when refresh rate changed.
+     */
+    oneway void onRefreshRateChangedDebug(in RefreshRateChangedDebugData data);
 }
diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/IComposerClient.aidl b/graphics/composer/aidl/android/hardware/graphics/composer3/IComposerClient.aidl
index 17924b9..fe6483e 100644
--- a/graphics/composer/aidl/android/hardware/graphics/composer3/IComposerClient.aidl
+++ b/graphics/composer/aidl/android/hardware/graphics/composer3/IComposerClient.aidl
@@ -850,4 +850,16 @@
      * @see getHdrConversionCapabilities
      */
     void setHdrConversionStrategy(in HdrConversionStrategy conversionStrategy);
+
+    /*
+     * Sets either the callback for the refresh rate change is enabled or disabled
+     * for the provided display.
+     *
+     * @see IComposerCallback.onRefreshRateChangedDebug
+     *
+     * @param display is the display on which the callback is enabled on.
+     * @param enabled true when refresh rate callback is enabled,
+     *        false when refresh rate callback is disabled.
+     */
+    void setRefreshRateChangedCallbackDebugEnabled(long display, boolean enabled);
 }
diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/RefreshRateChangedDebugData.aidl b/graphics/composer/aidl/android/hardware/graphics/composer3/RefreshRateChangedDebugData.aidl
new file mode 100644
index 0000000..c1f78d6
--- /dev/null
+++ b/graphics/composer/aidl/android/hardware/graphics/composer3/RefreshRateChangedDebugData.aidl
@@ -0,0 +1,30 @@
+/**
+ * Copyright 2023, 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.graphics.composer3;
+
+@VintfStability
+parcelable RefreshRateChangedDebugData {
+    /**
+     * The display for which the debug data is for.
+     */
+    long display;
+
+    /**
+     * The display vsync period in nanoseconds.
+     */
+    int vsyncPeriodNanos;
+}
diff --git a/graphics/composer/aidl/vts/GraphicsComposerCallback.cpp b/graphics/composer/aidl/vts/GraphicsComposerCallback.cpp
index d534943..4fb5d01 100644
--- a/graphics/composer/aidl/vts/GraphicsComposerCallback.cpp
+++ b/graphics/composer/aidl/vts/GraphicsComposerCallback.cpp
@@ -124,6 +124,12 @@
     return ::ndk::ScopedAStatus::ok();
 }
 
+::ndk::ScopedAStatus GraphicsComposerCallback::onRefreshRateChangedDebug(
+        const RefreshRateChangedDebugData&) {
+    // TODO(b/202734676) Add implementation for Vts tests
+    return ::ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
+}
+
 ::ndk::ScopedAStatus GraphicsComposerCallback::onVsyncPeriodTimingChanged(
         int64_t in_display,
         const ::aidl::android::hardware::graphics::composer3::VsyncPeriodChangeTimeline&
diff --git a/graphics/composer/aidl/vts/GraphicsComposerCallback.h b/graphics/composer/aidl/vts/GraphicsComposerCallback.h
index e54da34..9c3bc70 100644
--- a/graphics/composer/aidl/vts/GraphicsComposerCallback.h
+++ b/graphics/composer/aidl/vts/GraphicsComposerCallback.h
@@ -55,6 +55,8 @@
             const ::aidl::android::hardware::graphics::composer3::VsyncPeriodChangeTimeline&
                     in_updatedTimeline) override;
     virtual ::ndk::ScopedAStatus onVsyncIdle(int64_t in_display) override;
+    virtual ::ndk::ScopedAStatus onRefreshRateChangedDebug(
+            const RefreshRateChangedDebugData&) override;
 
     mutable std::mutex mMutex;
     // the set of all currently connected displays
diff --git a/graphics/composer/aidl/vts/VtsComposerClient.cpp b/graphics/composer/aidl/vts/VtsComposerClient.cpp
index f95e747..2e2b193 100644
--- a/graphics/composer/aidl/vts/VtsComposerClient.cpp
+++ b/graphics/composer/aidl/vts/VtsComposerClient.cpp
@@ -373,6 +373,12 @@
     return mComposerCallback->getVsyncIdleTime();
 }
 
+ndk::ScopedAStatus VtsComposerClient::setRefreshRateChangedCallbackDebugEnabled(
+        int64_t /* display */, bool /* enabled */) {
+    // TODO(b/202734676) Add implementation for VTS tests
+    return ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
+}
+
 int64_t VtsComposerClient::getInvalidDisplayId() {
     // returns an invalid display id (one that has not been registered to a
     // display. Currently assuming that a device will never have close to
diff --git a/graphics/composer/aidl/vts/VtsComposerClient.h b/graphics/composer/aidl/vts/VtsComposerClient.h
index 27788e7..aee46d2 100644
--- a/graphics/composer/aidl/vts/VtsComposerClient.h
+++ b/graphics/composer/aidl/vts/VtsComposerClient.h
@@ -196,6 +196,9 @@
 
     bool verifyComposerCallbackParams();
 
+    ndk::ScopedAStatus setRefreshRateChangedCallbackDebugEnabled(int64_t /* display */,
+                                                                 bool /* enabled */);
+
     // Keep track of displays and layers. When a test fails/ends,
     // the VtsComposerClient::tearDown should be called from the
     // test tearDown to clean up the resources for the test.
diff --git a/security/rkp/aidl/android/hardware/security/keymint/ProtectedData.aidl b/security/rkp/aidl/android/hardware/security/keymint/ProtectedData.aidl
index 57ee8cf..de94264 100644
--- a/security/rkp/aidl/android/hardware/security/keymint/ProtectedData.aidl
+++ b/security/rkp/aidl/android/hardware/security/keymint/ProtectedData.aidl
@@ -70,7 +70,7 @@
      *     ; HKDF. See details on use in ProtectedData comments above. The public key data
      *     ; included in the other field of PartyUInfo / PartyVInfo is encoded as:
      *     ;  - a raw 32-byte public key for X25519
-     *     ;  - uncompressed SEC-1 coordinate data (0x04 || x || y) for P-256
+     *     ;  - raw coordinate data (x || y) for P-256
      *     Context = [
      *         AlgorithmID : 3             ; AES-GCM 256
      *         PartyUInfo : [
diff --git a/thermal/aidl/aidl_api/android.hardware.thermal/current/android/hardware/thermal/CoolingDevice.aidl b/thermal/aidl/aidl_api/android.hardware.thermal/current/android/hardware/thermal/CoolingDevice.aidl
index dfd8686..dff3c4c 100644
--- a/thermal/aidl/aidl_api/android.hardware.thermal/current/android/hardware/thermal/CoolingDevice.aidl
+++ b/thermal/aidl/aidl_api/android.hardware.thermal/current/android/hardware/thermal/CoolingDevice.aidl
@@ -33,7 +33,7 @@
 
 package android.hardware.thermal;
 /* @hide */
-@VintfStability
+@JavaDerive(toString=true) @VintfStability
 parcelable CoolingDevice {
   android.hardware.thermal.CoolingType type;
   String name;
diff --git a/thermal/aidl/aidl_api/android.hardware.thermal/current/android/hardware/thermal/Temperature.aidl b/thermal/aidl/aidl_api/android.hardware.thermal/current/android/hardware/thermal/Temperature.aidl
index 3bf08bf..ce70ab8 100644
--- a/thermal/aidl/aidl_api/android.hardware.thermal/current/android/hardware/thermal/Temperature.aidl
+++ b/thermal/aidl/aidl_api/android.hardware.thermal/current/android/hardware/thermal/Temperature.aidl
@@ -33,7 +33,7 @@
 
 package android.hardware.thermal;
 /* @hide */
-@VintfStability
+@JavaDerive(toString=true) @VintfStability
 parcelable Temperature {
   android.hardware.thermal.TemperatureType type;
   String name;
diff --git a/thermal/aidl/aidl_api/android.hardware.thermal/current/android/hardware/thermal/TemperatureThreshold.aidl b/thermal/aidl/aidl_api/android.hardware.thermal/current/android/hardware/thermal/TemperatureThreshold.aidl
index c5ca4b9..a384d19 100644
--- a/thermal/aidl/aidl_api/android.hardware.thermal/current/android/hardware/thermal/TemperatureThreshold.aidl
+++ b/thermal/aidl/aidl_api/android.hardware.thermal/current/android/hardware/thermal/TemperatureThreshold.aidl
@@ -33,7 +33,7 @@
 
 package android.hardware.thermal;
 /* @hide */
-@VintfStability
+@JavaDerive(toString=true) @VintfStability
 parcelable TemperatureThreshold {
   android.hardware.thermal.TemperatureType type;
   String name;
diff --git a/thermal/aidl/android/hardware/thermal/CoolingDevice.aidl b/thermal/aidl/android/hardware/thermal/CoolingDevice.aidl
index 1f2360d..0c5c17d 100644
--- a/thermal/aidl/android/hardware/thermal/CoolingDevice.aidl
+++ b/thermal/aidl/android/hardware/thermal/CoolingDevice.aidl
@@ -20,6 +20,7 @@
 
 /* @hide */
 @VintfStability
+@JavaDerive(toString=true)
 parcelable CoolingDevice {
     /**
      * This cooling device type, CPU, GPU, BATTERY, and etc.
diff --git a/thermal/aidl/android/hardware/thermal/Temperature.aidl b/thermal/aidl/android/hardware/thermal/Temperature.aidl
index 281d68d..b3f6700 100644
--- a/thermal/aidl/android/hardware/thermal/Temperature.aidl
+++ b/thermal/aidl/android/hardware/thermal/Temperature.aidl
@@ -21,6 +21,7 @@
 
 /* @hide */
 @VintfStability
+@JavaDerive(toString=true)
 parcelable Temperature {
     /**
      * This temperature's type.
diff --git a/thermal/aidl/android/hardware/thermal/TemperatureThreshold.aidl b/thermal/aidl/android/hardware/thermal/TemperatureThreshold.aidl
index 0714c82..94991ae 100644
--- a/thermal/aidl/android/hardware/thermal/TemperatureThreshold.aidl
+++ b/thermal/aidl/android/hardware/thermal/TemperatureThreshold.aidl
@@ -20,6 +20,7 @@
 
 /* @hide */
 @VintfStability
+@JavaDerive(toString=true)
 parcelable TemperatureThreshold {
     /**
      * This temperature's type.
diff --git a/thermal/aidl/vts/VtsHalThermalTargetTest.cpp b/thermal/aidl/vts/VtsHalThermalTargetTest.cpp
index eb91e31..05cc8e0 100644
--- a/thermal/aidl/vts/VtsHalThermalTargetTest.cpp
+++ b/thermal/aidl/vts/VtsHalThermalTargetTest.cpp
@@ -95,20 +95,15 @@
 
         mThermalCallback = ndk::SharedRefBase::make<ThermalCallback>();
         ASSERT_NE(mThermalCallback, nullptr);
-        auto status = mThermal->registerThermalChangedCallback(mThermalCallback);
-        ASSERT_TRUE(status.isOk());
-        // Expect to fail if register again
-        status = mThermal->registerThermalChangedCallback(mThermalCallback);
-        ASSERT_FALSE(status.isOk());
-        ASSERT_EQ(EX_ILLEGAL_ARGUMENT, status.getExceptionCode());
+        ::ndk::ScopedAStatus status = mThermal->registerThermalChangedCallback(mThermalCallback);
+        ASSERT_TRUE(status.isOk()) << status.getMessage();
     }
 
     void TearDown() override {
-        auto status = mThermal->unregisterThermalChangedCallback(mThermalCallback);
-        ASSERT_TRUE(status.isOk());
+        ::ndk::ScopedAStatus status = mThermal->unregisterThermalChangedCallback(mThermalCallback);
+        ASSERT_TRUE(status.isOk()) << status.getMessage();
         // Expect to fail if unregister again
         status = mThermal->unregisterThermalChangedCallback(mThermalCallback);
-        ASSERT_FALSE(status.isOk());
         ASSERT_EQ(EX_ILLEGAL_ARGUMENT, status.getExceptionCode());
     }
 
@@ -121,11 +116,144 @@
 // This just calls into and back from our local ThermalChangedCallback impl.
 TEST_P(ThermalAidlTest, NotifyThrottlingTest) {
     std::shared_ptr<ThermalCallback> thermalCallback = ndk::SharedRefBase::make<ThermalCallback>();
-    auto ret = thermalCallback->notifyThrottling(kThrottleTemp);
-    ASSERT_TRUE(ret.isOk());
+    ::ndk::ScopedAStatus status = thermalCallback->notifyThrottling(kThrottleTemp);
+    ASSERT_TRUE(status.isOk()) << status.getMessage();
     ASSERT_TRUE(thermalCallback->waitForCallback(200ms));
 }
 
+// Test Thermal->registerThermalChangedCallback.
+TEST_P(ThermalAidlTest, RegisterThermalChangedCallbackTest) {
+    // Expect to fail with same callback
+    ::ndk::ScopedAStatus status = mThermal->registerThermalChangedCallback(mThermalCallback);
+    ASSERT_EQ(EX_ILLEGAL_ARGUMENT, status.getExceptionCode());
+    // Expect to fail with null callback
+    status = mThermal->registerThermalChangedCallback(nullptr);
+    ASSERT_EQ(EX_ILLEGAL_ARGUMENT, status.getExceptionCode());
+    std::shared_ptr<ThermalCallback> localThermalCallback =
+            ndk::SharedRefBase::make<ThermalCallback>();
+    // Expect to succeed with different callback
+    status = mThermal->registerThermalChangedCallback(localThermalCallback);
+    ASSERT_TRUE(status.isOk()) << status.getMessage();
+    ASSERT_TRUE(localThermalCallback->waitForCallback(200ms));
+    // Remove the local callback
+    status = mThermal->unregisterThermalChangedCallback(localThermalCallback);
+    ASSERT_TRUE(status.isOk()) << status.getMessage();
+    // Expect to fail with null callback
+    status = mThermal->unregisterThermalChangedCallback(nullptr);
+    ASSERT_EQ(EX_ILLEGAL_ARGUMENT, status.getExceptionCode());
+}
+
+// Test Thermal->registerThermalChangedCallbackWithType.
+TEST_P(ThermalAidlTest, RegisterThermalChangedCallbackWithTypeTest) {
+    // Expect to fail with same callback
+    ::ndk::ScopedAStatus status = mThermal->registerThermalChangedCallbackWithType(
+            mThermalCallback, TemperatureType::SKIN);
+    ASSERT_EQ(EX_ILLEGAL_ARGUMENT, status.getExceptionCode());
+    // Expect to fail with null callback
+    status = mThermal->registerThermalChangedCallbackWithType(nullptr, TemperatureType::SKIN);
+    ASSERT_EQ(EX_ILLEGAL_ARGUMENT, status.getExceptionCode());
+    std::shared_ptr<ThermalCallback> localThermalCallback =
+            ndk::SharedRefBase::make<ThermalCallback>();
+    // Expect to succeed with different callback
+    status = mThermal->registerThermalChangedCallbackWithType(localThermalCallback,
+                                                              TemperatureType::SKIN);
+    ASSERT_TRUE(status.isOk()) << status.getMessage();
+    ASSERT_TRUE(localThermalCallback->waitForCallback(200ms));
+    // Remove the local callback
+    status = mThermal->unregisterThermalChangedCallback(localThermalCallback);
+    ASSERT_TRUE(status.isOk()) << status.getMessage();
+    // Expect to fail with null callback
+    status = mThermal->unregisterThermalChangedCallback(nullptr);
+    ASSERT_EQ(EX_ILLEGAL_ARGUMENT, status.getExceptionCode());
+}
+
+// Test Thermal->getCurrentTemperatures().
+TEST_P(ThermalAidlTest, TemperatureTest) {
+    std::vector<Temperature> ret;
+    ::ndk::ScopedAStatus status = mThermal->getTemperatures(&ret);
+    if (status.isOk()) {
+        for (auto& i : ret) {
+            EXPECT_LT(0u, i.name.size());
+            LOG(INFO) << i.name + " " + toString(i.type) << "\n";
+        }
+    } else {
+        ASSERT_EQ(EX_ILLEGAL_STATE, status.getExceptionCode());
+    }
+
+    auto types = ::ndk::enum_range<TemperatureType>();
+    for (const auto& type : types) {
+        status = mThermal->getTemperaturesWithType(type, &ret);
+
+        if (status.isOk()) {
+            for (auto& i : ret) {
+                EXPECT_EQ(type, i.type) << "Expect type " + toString(type) + " but got " +
+                                                   toString(i.type) + " for " + i.name;
+                EXPECT_LT(0u, i.name.size());
+            }
+        } else {
+            ASSERT_EQ(EX_ILLEGAL_STATE, status.getExceptionCode());
+        }
+    }
+}
+
+// Test Thermal->getTemperatureThresholds().
+TEST_P(ThermalAidlTest, TemperatureThresholdTest) {
+    std::vector<TemperatureThreshold> ret;
+    ::ndk::ScopedAStatus status = mThermal->getTemperatureThresholds(&ret);
+    if (status.isOk()) {
+        for (auto& i : ret) {
+            EXPECT_LT(0u, i.name.size());
+            LOG(INFO) << i.name + " " + toString(i.type) << "\n";
+        }
+    } else {
+        ASSERT_EQ(EX_ILLEGAL_STATE, status.getExceptionCode());
+    }
+
+    auto types = ::ndk::enum_range<TemperatureType>();
+    for (const auto& type : types) {
+        status = mThermal->getTemperatureThresholdsWithType(type, &ret);
+
+        if (status.isOk()) {
+            for (auto& i : ret) {
+                EXPECT_EQ(type, i.type) << "Expect type " + toString(type) + " but got " +
+                                                   toString(i.type) + " for " + i.name;
+                EXPECT_LT(0u, i.name.size());
+            }
+        } else {
+            ASSERT_EQ(EX_ILLEGAL_STATE, status.getExceptionCode());
+        }
+    }
+}
+
+// Test Thermal->getCoolingDevices().
+TEST_P(ThermalAidlTest, CoolingDeviceTest) {
+    std::vector<CoolingDevice> ret;
+    ::ndk::ScopedAStatus status = mThermal->getCoolingDevices(&ret);
+    if (status.isOk()) {
+        for (auto& i : ret) {
+            EXPECT_LT(0u, i.name.size());
+            LOG(INFO) << i.name + " " + toString(i.type) << "\n";
+        }
+    } else {
+        ASSERT_EQ(EX_ILLEGAL_STATE, status.getExceptionCode());
+    }
+
+    auto types = ::ndk::enum_range<CoolingType>();
+    for (const auto& type : types) {
+        status = mThermal->getCoolingDevicesWithType(type, &ret);
+        if (status.isOk()) {
+            ASSERT_TRUE(status.isOk());
+            for (auto& i : ret) {
+                EXPECT_EQ(type, i.type) << "Expect type " + toString(type) + " but got " +
+                                                   toString(i.type) + " for " + i.name;
+                EXPECT_LT(0u, i.name.size());
+            }
+        } else {
+            ASSERT_EQ(EX_ILLEGAL_STATE, status.getExceptionCode());
+        }
+    }
+}
+
 GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(ThermalAidlTest);
 INSTANTIATE_TEST_SUITE_P(
         Thermal, ThermalAidlTest,
diff --git a/tv/hdmi/connection/aidl/default/HdmiConnectionMock.cpp b/tv/hdmi/connection/aidl/default/HdmiConnectionMock.cpp
index ca8c348..8f4411b 100644
--- a/tv/hdmi/connection/aidl/default/HdmiConnectionMock.cpp
+++ b/tv/hdmi/connection/aidl/default/HdmiConnectionMock.cpp
@@ -70,16 +70,21 @@
 }
 
 ScopedAStatus HdmiConnectionMock::setHpdSignal(HpdSignal signal, int32_t portId) {
-    if (mHdmiThreadRun) {
-        mHpdSignal.at(portId - 1) = signal;
-        return ScopedAStatus::ok();
-    } else {
+    if (portId > mTotalPorts || portId < 1) {
+        return ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
+    }
+    if (!mHdmiThreadRun) {
         return ScopedAStatus::fromServiceSpecificError(
                 static_cast<int32_t>(Result::FAILURE_INVALID_STATE));
     }
+    mHpdSignal.at(portId - 1) = signal;
+    return ScopedAStatus::ok();
 }
 
 ScopedAStatus HdmiConnectionMock::getHpdSignal(int32_t portId, HpdSignal* _aidl_return) {
+    if (portId > mTotalPorts || portId < 1) {
+        return ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
+    }
     *_aidl_return = mHpdSignal.at(portId - 1);
     return ScopedAStatus::ok();
 }
@@ -123,7 +128,7 @@
     bool connected = ((msgBuf[3]) & 0xf) > 0;
     int32_t portId = static_cast<uint32_t>(msgBuf[0] & 0xf);
 
-    if (portId > static_cast<int32_t>(mPortInfos.size())) {
+    if (portId > static_cast<int32_t>(mPortInfos.size()) || portId < 1) {
         ALOGD("[halimp_aidl] ignore hot plug message, id %x does not exist", portId);
         return;
     }
diff --git a/wifi/supplicant/aidl/aidl_api/android.hardware.wifi.supplicant/current/android/hardware/wifi/supplicant/INonStandardCertCallback.aidl b/wifi/supplicant/aidl/aidl_api/android.hardware.wifi.supplicant/current/android/hardware/wifi/supplicant/INonStandardCertCallback.aidl
index 28c1028..bcf0ea8 100644
--- a/wifi/supplicant/aidl/aidl_api/android.hardware.wifi.supplicant/current/android/hardware/wifi/supplicant/INonStandardCertCallback.aidl
+++ b/wifi/supplicant/aidl/aidl_api/android.hardware.wifi.supplicant/current/android/hardware/wifi/supplicant/INonStandardCertCallback.aidl
@@ -35,4 +35,5 @@
 @VintfStability
 interface INonStandardCertCallback {
   byte[] getBlob(in String alias);
+  String[] listAliases(in String prefix);
 }
diff --git a/wifi/supplicant/aidl/android/hardware/wifi/supplicant/INonStandardCertCallback.aidl b/wifi/supplicant/aidl/android/hardware/wifi/supplicant/INonStandardCertCallback.aidl
index 3259585..2f9e528 100644
--- a/wifi/supplicant/aidl/android/hardware/wifi/supplicant/INonStandardCertCallback.aidl
+++ b/wifi/supplicant/aidl/android/hardware/wifi/supplicant/INonStandardCertCallback.aidl
@@ -34,4 +34,13 @@
      *         |SupplicantStatusCode.FAILURE_UNKNOWN|
      */
     byte[] getBlob(in String alias);
+
+    /**
+     * List the aliases currently stored in the database.
+     *
+     * @param prefix Prefix to filter the aliases by.
+     * @return List of alias strings in the certificate store.
+               The resulting strings will each exclude the prefix.
+     */
+    String[] listAliases(in String prefix);
 }