Added Telephony DSDA Support to the HAL.

This CL updates the relevant aidl files to allow the modem to dynamically inform telephony of whether simultaneos cellular calling is supported.

Bug: 311495663
Test: VTS
Change-Id: Ie1e10a50227e8a53fc62a5822a0a115b101ef388
diff --git a/radio/aidl/aidl_api/android.hardware.radio.config/current/android/hardware/radio/config/IRadioConfig.aidl b/radio/aidl/aidl_api/android.hardware.radio.config/current/android/hardware/radio/config/IRadioConfig.aidl
index 0f5e7e4..bc1c292 100644
--- a/radio/aidl/aidl_api/android.hardware.radio.config/current/android/hardware/radio/config/IRadioConfig.aidl
+++ b/radio/aidl/aidl_api/android.hardware.radio.config/current/android/hardware/radio/config/IRadioConfig.aidl
@@ -51,4 +51,5 @@
   oneway void setPreferredDataModem(in int serial, in byte modemId);
   oneway void setResponseFunctions(in android.hardware.radio.config.IRadioConfigResponse radioConfigResponse, in android.hardware.radio.config.IRadioConfigIndication radioConfigIndication);
   oneway void setSimSlotsMapping(in int serial, in android.hardware.radio.config.SlotPortMapping[] slotMap);
+  oneway void getSimultaneousCallingSupport(in int serial);
 }
diff --git a/radio/aidl/aidl_api/android.hardware.radio.config/current/android/hardware/radio/config/IRadioConfigIndication.aidl b/radio/aidl/aidl_api/android.hardware.radio.config/current/android/hardware/radio/config/IRadioConfigIndication.aidl
index 9189f90..f786373 100644
--- a/radio/aidl/aidl_api/android.hardware.radio.config/current/android/hardware/radio/config/IRadioConfigIndication.aidl
+++ b/radio/aidl/aidl_api/android.hardware.radio.config/current/android/hardware/radio/config/IRadioConfigIndication.aidl
@@ -36,4 +36,5 @@
 @VintfStability
 interface IRadioConfigIndication {
   oneway void simSlotsStatusChanged(in android.hardware.radio.RadioIndicationType type, in android.hardware.radio.config.SimSlotStatus[] slotStatus);
+  oneway void onSimultaneousCallingSupportChanged(in int[] enabledLogicalSlots);
 }
diff --git a/radio/aidl/aidl_api/android.hardware.radio.config/current/android/hardware/radio/config/IRadioConfigResponse.aidl b/radio/aidl/aidl_api/android.hardware.radio.config/current/android/hardware/radio/config/IRadioConfigResponse.aidl
index 348aa34..6ff7bd0 100644
--- a/radio/aidl/aidl_api/android.hardware.radio.config/current/android/hardware/radio/config/IRadioConfigResponse.aidl
+++ b/radio/aidl/aidl_api/android.hardware.radio.config/current/android/hardware/radio/config/IRadioConfigResponse.aidl
@@ -42,4 +42,5 @@
   oneway void setNumOfLiveModemsResponse(in android.hardware.radio.RadioResponseInfo info);
   oneway void setPreferredDataModemResponse(in android.hardware.radio.RadioResponseInfo info);
   oneway void setSimSlotsMappingResponse(in android.hardware.radio.RadioResponseInfo info);
+  oneway void getSimultaneousCallingSupportResponse(in android.hardware.radio.RadioResponseInfo info, in int[] enabledLogicalSlots);
 }
diff --git a/radio/aidl/aidl_api/android.hardware.radio.config/current/android/hardware/radio/config/PhoneCapability.aidl b/radio/aidl/aidl_api/android.hardware.radio.config/current/android/hardware/radio/config/PhoneCapability.aidl
index 3648866..2c66abd 100644
--- a/radio/aidl/aidl_api/android.hardware.radio.config/current/android/hardware/radio/config/PhoneCapability.aidl
+++ b/radio/aidl/aidl_api/android.hardware.radio.config/current/android/hardware/radio/config/PhoneCapability.aidl
@@ -39,4 +39,6 @@
   byte maxActiveInternetData;
   boolean isInternetLingeringSupported;
   byte[] logicalModemIds;
+  byte maxActiveVoice = UNKNOWN /* -1 */;
+  const byte UNKNOWN = (-1) /* -1 */;
 }
diff --git a/radio/aidl/android/hardware/radio/config/IRadioConfig.aidl b/radio/aidl/android/hardware/radio/config/IRadioConfig.aidl
index 9058d9d..8f4dff4 100644
--- a/radio/aidl/android/hardware/radio/config/IRadioConfig.aidl
+++ b/radio/aidl/android/hardware/radio/config/IRadioConfig.aidl
@@ -191,4 +191,20 @@
      * This is available when android.hardware.telephony.subscription is defined.
      */
     void setSimSlotsMapping(in int serial, in SlotPortMapping[] slotMap);
+
+    /**
+     * Get the set of logical slots where simultaneous cellular calling is currently possible. This
+     * does not include simultaneous calling availability over other non-cellular transports, such
+     * as IWLAN.
+     *
+     * Get the set of slots that currently support simultaneous cellular calling. When a new
+     * cellular call is placed/received, if another slot is active and handing a call, both the
+     * active slot and proposed slot must be in this list in order to support simultaneous cellular
+     * calling for both of those slots.
+     *
+     * @param serial Serial number of request
+     *
+     * This is available when android.hardware.telephony is defined.
+     */
+    void getSimultaneousCallingSupport(in int serial);
 }
diff --git a/radio/aidl/android/hardware/radio/config/IRadioConfigIndication.aidl b/radio/aidl/android/hardware/radio/config/IRadioConfigIndication.aidl
index ed2366b..9eacb8e 100644
--- a/radio/aidl/android/hardware/radio/config/IRadioConfigIndication.aidl
+++ b/radio/aidl/android/hardware/radio/config/IRadioConfigIndication.aidl
@@ -37,4 +37,15 @@
      */
     void simSlotsStatusChanged(
             in android.hardware.radio.RadioIndicationType type, in SimSlotStatus[] slotStatus);
+
+    /**
+     * The logical slots supporting simultaneous cellular calling has changed.
+     *
+     * @param enabledLogicalSlots The slots that have simultaneous cellular calling enabled. If
+     * there is a call active on logical slot X, then a simultaneous cellular call is only possible
+     * on logical slot Y if BOTH slot X and slot Y are in enabledLogicalSlots. If simultaneous
+     * cellular calling is not currently supported, the expected value of enabledLogicalSLots is an
+     * empty int array. Sending only one radio slot is not acceptable in any case.
+     */
+    void onSimultaneousCallingSupportChanged(in int[] enabledLogicalSlots);
 }
diff --git a/radio/aidl/android/hardware/radio/config/IRadioConfigResponse.aidl b/radio/aidl/android/hardware/radio/config/IRadioConfigResponse.aidl
index df93e3c..33b0ff0 100644
--- a/radio/aidl/android/hardware/radio/config/IRadioConfigResponse.aidl
+++ b/radio/aidl/android/hardware/radio/config/IRadioConfigResponse.aidl
@@ -129,4 +129,27 @@
      *   RadioError:INVALID_ARGUMENTS
      */
     void setSimSlotsMappingResponse(in android.hardware.radio.RadioResponseInfo info);
+
+    /**
+     * Response to the asynchronous
+     * {@link IRadioConfig#getSimultaneousCallingSupport} request.
+     *
+     * @param info Response info struct containing response type, serial no. and error
+     * @param enabledLogicalSlots The slots that have simultaneous cellular calling enabled. If
+     * there is a call active on logical slot X, then a simultaneous cellular call is only possible
+     * on logical slot Y if BOTH slot X and slot Y are in enabledLogicalSlots. If simultaneous
+     * cellular calling is not currently supported, the expected value of enabledLogicalSLots is an
+     * empty int array. Sending only one radio slot is not acceptable in any case.
+     *
+     * Valid errors returned:
+     *   RadioError:REQUEST_NOT_SUPPORTED when android.hardware.telephony is not defined
+     *   RadioError:NONE
+     *   RadioError:RADIO_NOT_AVAILABLE
+     *   RadioError:INTERNAL_ERR
+     *   RadioError:MODEM_ERR
+     *
+     * @see IRadioConfig#getSimultaneousCallingSupport for more information.
+     */
+    void getSimultaneousCallingSupportResponse(
+            in android.hardware.radio.RadioResponseInfo info, in int[] enabledLogicalSlots);
 }
diff --git a/radio/aidl/android/hardware/radio/config/PhoneCapability.aidl b/radio/aidl/android/hardware/radio/config/PhoneCapability.aidl
index 35d6b5d..7936eb6 100644
--- a/radio/aidl/android/hardware/radio/config/PhoneCapability.aidl
+++ b/radio/aidl/android/hardware/radio/config/PhoneCapability.aidl
@@ -25,6 +25,7 @@
 @VintfStability
 @JavaDerive(toString=true)
 parcelable PhoneCapability {
+    const byte UNKNOWN = -1;
     /**
      * maxActiveData defines how many logical modems can have
      * PS attached simultaneously. For example, for L+L modem it
@@ -47,4 +48,10 @@
      * List of logical modem IDs.
      */
     byte[] logicalModemIds;
+    /**
+     * maxActiveVoice defines how many logical modems can have
+     * cellular voice calls simultaneously. For example, for cellular DSDA
+     * with simultaneous calling support, it should be 2.
+     */
+    byte maxActiveVoice = UNKNOWN;
 }
diff --git a/radio/aidl/compat/libradiocompat/config/RadioConfig.cpp b/radio/aidl/compat/libradiocompat/config/RadioConfig.cpp
index b450418..837c626 100644
--- a/radio/aidl/compat/libradiocompat/config/RadioConfig.cpp
+++ b/radio/aidl/compat/libradiocompat/config/RadioConfig.cpp
@@ -62,6 +62,13 @@
     return ok();
 }
 
+ScopedAStatus RadioConfig::getSimultaneousCallingSupport(int32_t serial) {
+    LOG_CALL << serial;
+    LOG(ERROR) << " getSimultaneousCallingSupport is unsupported by HIDL HALs";
+    respond()->getSimultaneousCallingSupportResponse(notSupported(serial), {});
+    return ok();
+}
+
 ScopedAStatus RadioConfig::getSimSlotsStatus(int32_t serial) {
     LOG_CALL << serial;
     mHal1_1->getSimSlotsStatus(serial);
diff --git a/radio/aidl/compat/libradiocompat/include/libradiocompat/RadioConfig.h b/radio/aidl/compat/libradiocompat/include/libradiocompat/RadioConfig.h
index 89ddea0..17d5985 100644
--- a/radio/aidl/compat/libradiocompat/include/libradiocompat/RadioConfig.h
+++ b/radio/aidl/compat/libradiocompat/include/libradiocompat/RadioConfig.h
@@ -42,6 +42,7 @@
     ::ndk::ScopedAStatus getHalDeviceCapabilities(int32_t serial) override;
     ::ndk::ScopedAStatus getNumOfLiveModems(int32_t serial) override;
     ::ndk::ScopedAStatus getPhoneCapability(int32_t serial) override;
+    ::ndk::ScopedAStatus getSimultaneousCallingSupport(int32_t serial) override;
     ::ndk::ScopedAStatus getSimSlotsStatus(int32_t serial) override;
     ::ndk::ScopedAStatus setNumOfLiveModems(int32_t serial, int8_t numOfLiveModems) override;
     ::ndk::ScopedAStatus setPreferredDataModem(int32_t serial, int8_t modemId) override;
diff --git a/radio/aidl/vts/radio_config_indication.cpp b/radio/aidl/vts/radio_config_indication.cpp
index a84c20b..c707663 100644
--- a/radio/aidl/vts/radio_config_indication.cpp
+++ b/radio/aidl/vts/radio_config_indication.cpp
@@ -22,3 +22,8 @@
         RadioIndicationType /*type*/, const std::vector<SimSlotStatus>& /*slotStatus*/) {
     return ndk::ScopedAStatus::ok();
 }
+
+ndk::ScopedAStatus RadioConfigIndication::onSimultaneousCallingSupportChanged(
+        const std::vector<int32_t>& /*enabledLogicalSlots*/) {
+    return ndk::ScopedAStatus::ok();
+}
diff --git a/radio/aidl/vts/radio_config_response.cpp b/radio/aidl/vts/radio_config_response.cpp
index 7384f87..dccbd0e 100644
--- a/radio/aidl/vts/radio_config_response.cpp
+++ b/radio/aidl/vts/radio_config_response.cpp
@@ -40,6 +40,13 @@
     return ndk::ScopedAStatus::ok();
 }
 
+ndk::ScopedAStatus RadioConfigResponse::getSimultaneousCallingSupportResponse(
+        const RadioResponseInfo& info, const std::vector<int32_t>& /* enabledLogicalSlots */) {
+    rspInfo = info;
+    parent_config.notify(info.serial);
+    return ndk::ScopedAStatus::ok();
+}
+
 ndk::ScopedAStatus RadioConfigResponse::setPreferredDataModemResponse(
         const RadioResponseInfo& info) {
     rspInfo = info;
diff --git a/radio/aidl/vts/radio_config_test.cpp b/radio/aidl/vts/radio_config_test.cpp
index d8c0142..f725136 100644
--- a/radio/aidl/vts/radio_config_test.cpp
+++ b/radio/aidl/vts/radio_config_test.cpp
@@ -122,6 +122,41 @@
 }
 
 /*
+ * Test IRadioConfig.getSimultaneousCallingSupport() for the response returned.
+ */
+TEST_P(RadioConfigTest, getSimultaneousCallingSupport) {
+    if (telephony_flags::enforce_telephony_feature_mapping()) {
+        if (!deviceSupportsFeature(FEATURE_TELEPHONY)) {
+            GTEST_SKIP() << "Skipping getSimultaneousCallingSupport "
+                            "due to undefined FEATURE_TELEPHONY";
+        }
+    }
+
+    int32_t aidl_version;
+    ndk::ScopedAStatus aidl_status = radio_config->getInterfaceVersion(&aidl_version);
+    ASSERT_OK(aidl_status);
+    if (aidl_version < 3) {
+        ALOGI("Skipped the test since"
+                " getSimultaneousCallingSupport is not supported on version < 3.");
+        GTEST_SKIP();
+    }
+
+    serial = GetRandomSerialNumber();
+    ndk::ScopedAStatus res = radio_config->getSimultaneousCallingSupport(serial);
+    ASSERT_OK(res);
+    EXPECT_EQ(std::cv_status::no_timeout, wait());
+    EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_config->rspInfo.type);
+    EXPECT_EQ(serial, radioRsp_config->rspInfo.serial);
+    ALOGI("getSimultaneousCallingSupport, rspInfo.error = %s\n",
+          toString(radioRsp_config->rspInfo.error).c_str());
+
+    ASSERT_TRUE(CheckAnyOfErrors(
+            radioRsp_config->rspInfo.error,
+            {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE, RadioError::INTERNAL_ERR,
+            RadioError::MODEM_ERR, RadioError::REQUEST_NOT_SUPPORTED}));
+}
+
+/*
  * Test IRadioConfig.setPreferredDataModem() for the response returned.
  */
 TEST_P(RadioConfigTest, setPreferredDataModem) {
diff --git a/radio/aidl/vts/radio_config_utils.h b/radio/aidl/vts/radio_config_utils.h
index f79aedb..9e809ff 100644
--- a/radio/aidl/vts/radio_config_utils.h
+++ b/radio/aidl/vts/radio_config_utils.h
@@ -48,6 +48,9 @@
     virtual ndk::ScopedAStatus getPhoneCapabilityResponse(
             const RadioResponseInfo& info, const PhoneCapability& phoneCapability) override;
 
+    virtual ndk::ScopedAStatus getSimultaneousCallingSupportResponse(
+            const RadioResponseInfo& info, const std::vector<int32_t>& enabledLogicalSlots) override;
+
     virtual ndk::ScopedAStatus setPreferredDataModemResponse(
             const RadioResponseInfo& info) override;
 
@@ -71,6 +74,9 @@
 
     virtual ndk::ScopedAStatus simSlotsStatusChanged(
             RadioIndicationType type, const std::vector<SimSlotStatus>& slotStatus) override;
+
+    virtual ndk::ScopedAStatus onSimultaneousCallingSupportChanged(
+            const std::vector<int32_t>& /*enabledLogicalSlots*/) override;
 };
 
 // The main test class for Radio AIDL Config.