Merge changes from topic "cherrypicker-L52200000960664466:N84600001369065936" into udc-qpr-dev

* changes:
  Improve AudioProvider logging
  Fix deathRecipient of BluetoothAudioProvider
diff --git a/audio/aidl/default/Config.cpp b/audio/aidl/default/Config.cpp
index 87c0ace..e87af07 100644
--- a/audio/aidl/default/Config.cpp
+++ b/audio/aidl/default/Config.cpp
@@ -47,10 +47,14 @@
                 LOG(WARNING) << __func__ << mAudioPolicyConverter.getError();
             }
         }
+        // Logging full contents of the config is an overkill, just provide statistics.
+        LOG(DEBUG) << "getEngineConfig: number of strategies parsed: "
+                   << engConfig.productStrategies.size()
+                   << ", default strategy: " << engConfig.defaultProductStrategyId
+                   << ", number of volume groups parsed: " << engConfig.volumeGroups.size();
         return engConfig;
     }();
     *_aidl_return = returnEngCfg;
-    LOG(DEBUG) << __func__ << ": returning " << _aidl_return->toString();
     return ndk::ScopedAStatus::ok();
 }
 }  // namespace aidl::android::hardware::audio::core
diff --git a/audio/aidl/default/Configuration.cpp b/audio/aidl/default/Configuration.cpp
index e1e1f79..d41ea67 100644
--- a/audio/aidl/default/Configuration.cpp
+++ b/audio/aidl/default/Configuration.cpp
@@ -81,6 +81,8 @@
         deviceExt.device.address = "bottom";
     } else if (devType == AudioDeviceType::IN_MICROPHONE_BACK && connection.empty()) {
         deviceExt.device.address = "back";
+    } else if (devType == AudioDeviceType::IN_SUBMIX || devType == AudioDeviceType::OUT_SUBMIX) {
+        deviceExt.device.address = "0";
     }
     deviceExt.device.type.connection = std::move(connection);
     deviceExt.flags = flags;
@@ -365,8 +367,10 @@
 
         // Device ports
 
-        AudioPort rsubmixOutDevice = createPort(c.nextPortId++, "Remote Submix Out", 0, false,
-                                                createDeviceExt(AudioDeviceType::OUT_SUBMIX, 0));
+        AudioPort rsubmixOutDevice =
+                createPort(c.nextPortId++, "Remote Submix Out", 0, false,
+                           createDeviceExt(AudioDeviceType::OUT_SUBMIX, 0,
+                                           AudioDeviceDescription::CONNECTION_VIRTUAL));
         rsubmixOutDevice.profiles.push_back(
                 createProfile(PcmType::INT_24_BIT, {AudioChannelLayout::LAYOUT_STEREO}, {48000}));
         c.ports.push_back(rsubmixOutDevice);
diff --git a/automotive/audiocontrol/aidl/vts/VtsHalAudioControlTargetTest.cpp b/automotive/audiocontrol/aidl/vts/VtsHalAudioControlTargetTest.cpp
index f4e3b5a..4e7e963 100644
--- a/automotive/audiocontrol/aidl/vts/VtsHalAudioControlTargetTest.cpp
+++ b/automotive/audiocontrol/aidl/vts/VtsHalAudioControlTargetTest.cpp
@@ -53,17 +53,25 @@
 namespace audiohalcommon = android::hardware::audio::common;
 namespace audiomediacommon = android::media::audio::common;
 
+namespace {
+constexpr int32_t kAidlVersionThree = 3;
+}
+
 class AudioControlAidl : public testing::TestWithParam<std::string> {
   public:
     virtual void SetUp() override {
         audioControl = android::waitForDeclaredService<IAudioControl>(String16(GetParam().c_str()));
         ASSERT_NE(audioControl, nullptr);
+        aidlVersion = audioControl->getInterfaceVersion();
     }
 
     void TearDown() override { audioControl = nullptr; }
 
+    bool isAidlVersionAtleast(int version) const { return aidlVersion >= version; }
+
     sp<IAudioControl> audioControl;
     int32_t capabilities;
+    int32_t aidlVersion;
 };
 
 TEST_P(AudioControlAidl, OnSetFadeTowardsFront) {
@@ -250,6 +258,11 @@
 
 TEST_P(AudioControlAidl, RegisterModuleChangeCallbackTwiceThrowsException) {
     ALOGI("Register Module change callback test");
+    if (!isAidlVersionAtleast(kAidlVersionThree)) {
+        GTEST_SKIP() << "Device does not support the new APIs for module change callback";
+        return;
+    }
+
     // make sure no stale callbacks.
     audioControl->clearModuleChangeCallback();
 
@@ -269,6 +282,11 @@
 
 TEST_P(AudioControlAidl, RegisterModuleChangeNullCallbackThrowsException) {
     ALOGI("Register Module change callback with nullptr test");
+    if (!isAidlVersionAtleast(kAidlVersionThree)) {
+        GTEST_SKIP() << "Device does not support the new APIs for module change callback";
+        return;
+    }
+
     auto status = audioControl->setModuleChangeCallback(nullptr);
     EXPECT_THAT(status.exceptionCode(),
                 AnyOf(Eq(Status::EX_ILLEGAL_ARGUMENT), Eq(Status::EX_UNSUPPORTED_OPERATION)));
diff --git a/identity/aidl/vts/VtsIWritableIdentityCredentialTests.cpp b/identity/aidl/vts/VtsIWritableIdentityCredentialTests.cpp
index 94d4c88..eb74fa2 100644
--- a/identity/aidl/vts/VtsIWritableIdentityCredentialTests.cpp
+++ b/identity/aidl/vts/VtsIWritableIdentityCredentialTests.cpp
@@ -125,7 +125,8 @@
 
     MacedPublicKey macedPublicKey;
     std::vector<uint8_t> attestationKey;
-    result = rpc->generateEcdsaP256KeyPair(/*testMode=*/true, &macedPublicKey, &attestationKey);
+    // Start by RPC version 3, we don't support testMode=true. So just verify testMode=false here.
+    result = rpc->generateEcdsaP256KeyPair(/*testMode=*/false, &macedPublicKey, &attestationKey);
     ASSERT_TRUE(result.isOk()) << result.exceptionCode() << "; " << result.exceptionMessage();
 
     optional<vector<vector<uint8_t>>> remotelyProvisionedCertChain =
@@ -176,7 +177,8 @@
 
     MacedPublicKey macedPublicKey;
     std::vector<uint8_t> attestationKey;
-    result = rpc->generateEcdsaP256KeyPair(/*testMode=*/true, &macedPublicKey, &attestationKey);
+    // Start by RPC version 3, we don't support testMode=true. So just verify testMode=false here.
+    result = rpc->generateEcdsaP256KeyPair(/*testMode=*/false, &macedPublicKey, &attestationKey);
     ASSERT_TRUE(result.isOk()) << result.exceptionCode() << "; " << result.exceptionMessage();
 
     optional<vector<vector<uint8_t>>> remotelyProvisionedCertChain =
diff --git a/tv/input/aidl/android/hardware/tv/input/ITvInputCallback.aidl b/tv/input/aidl/android/hardware/tv/input/ITvInputCallback.aidl
index 5d47317..2c7e32f 100644
--- a/tv/input/aidl/android/hardware/tv/input/ITvInputCallback.aidl
+++ b/tv/input/aidl/android/hardware/tv/input/ITvInputCallback.aidl
@@ -30,7 +30,14 @@
     void notify(in TvInputEvent event);
     /**
      * Notifies the client that an TV message event has occurred. For possible event types,
-     * check TvMessageEventType.
+     * check {@link android.hardware.tv.input.TvMessageEventType}.
+     *
+     * The first message in a list of messages contained in a
+     * {@link android.hardware.tv.input.TvMessageEvent} should always have a
+     * {@link android.hardware.tv.input.TvMessage#subType} of "device_id",
+     * otherwise the event is discarded. When the subType of a message is "device_id", the ID of
+     * the device that sent the message should be contained in
+     * {@link android.hardware.tv.input.TvMessage#groupId}
      *
      * @param event Event passed to the client.
      */
diff --git a/tv/input/aidl/android/hardware/tv/input/TvMessage.aidl b/tv/input/aidl/android/hardware/tv/input/TvMessage.aidl
index 88da538..afa48a9 100644
--- a/tv/input/aidl/android/hardware/tv/input/TvMessage.aidl
+++ b/tv/input/aidl/android/hardware/tv/input/TvMessage.aidl
@@ -23,8 +23,13 @@
      */
     const long NO_GROUP_ID = -1;
     /**
-     * Extended data type, like “ATSC A/336 Watermark”, “ATSC_CC”, etc. This is opaque
-     * to the framework.
+     * Extended data type, like “ATSC A/336 Watermark”, “ATSC_CC”, etc. This type is opaque to the
+     * framework except when the subtype is "device_id". If the subtype is "device_id", the ID of
+     * device that sent the message should be contained in {@link #groupId}.
+     *
+     * The first message in a list of messages contained in
+     * {@link android.hardware.tv.input.TvMessageEvent} should always have the subtype "device_id",
+     * otherwise the event is discarded.
      */
     String subType;
     /**
@@ -32,6 +37,9 @@
      * headers and bodies of the same event. For messages that do not have a group, this value
      * should be -1.
      *
+     * If {@link #subType} is "device_id", this value should contain the ID of the device that sent
+     * this message.
+     *
      * As -1 is a reserved value, -1 should not be used as a valid groupId.
      */
     long groupId;