[uci] Pass in a boolean to indicate if support multicast ntf v2.

This is a temporary fix for Pixel devices that are using Fira 2.0 while
still using multicast ntf v1.

Bug: 333989564
Test: atest CtsUwbTestCases
Test: atest libuwb_core_tests
Change-Id: Ib45ce604a4e3ad0717b333d523e681a75cdc18b3
diff --git a/src/rust/uwb_core/src/session/uwb_session.rs b/src/rust/uwb_core/src/session/uwb_session.rs
index d41b693..7e82e0a 100644
--- a/src/rust/uwb_core/src/session/uwb_session.rs
+++ b/src/rust/uwb_core/src/session/uwb_session.rs
@@ -312,6 +312,7 @@
                 self.session_id,
                 action,
                 Controlees::NoSessionKey(controlees),
+                false,
             )
             .await?;
 
diff --git a/src/rust/uwb_core/src/uci/command.rs b/src/rust/uwb_core/src/uci/command.rs
index b15d387..51cbdcb 100644
--- a/src/rust/uwb_core/src/uci/command.rs
+++ b/src/rust/uwb_core/src/uci/command.rs
@@ -68,6 +68,7 @@
         session_token: SessionToken,
         action: UpdateMulticastListAction,
         controlees: Controlees,
+        is_multicast_list_ntf_v2_supported: bool,
     },
     SessionUpdateDtTagRangingRounds {
         session_token: u32,
@@ -146,6 +147,7 @@
                 session_token,
                 action,
                 controlees,
+                ..
             } => build_session_update_controller_multicast_list_cmd(
                 session_token,
                 action,
@@ -406,6 +408,7 @@
             session_token: 1,
             action: UpdateMulticastListAction::AddControlee,
             controlees: Controlees::NoSessionKey(vec![]),
+            is_multicast_list_ntf_v2_supported: false,
         };
         packet = uwb_uci_packets::UciControlPacket::try_from(cmd.clone()).unwrap();
         assert_eq!(
diff --git a/src/rust/uwb_core/src/uci/message.rs b/src/rust/uwb_core/src/uci/message.rs
index a4f72e8..b0f4c22 100644
--- a/src/rust/uwb_core/src/uci/message.rs
+++ b/src/rust/uwb_core/src/uci/message.rs
@@ -28,19 +28,22 @@
     Notification(UciNotification),
 }
 
-impl TryFrom<(uwb_uci_packets::UciControlPacket, UCIMajorVersion)> for UciMessage {
+impl TryFrom<(uwb_uci_packets::UciControlPacket, UCIMajorVersion, bool)> for UciMessage {
     type Error = Error;
     fn try_from(
-        pair: (uwb_uci_packets::UciControlPacket, UCIMajorVersion),
+        pair: (uwb_uci_packets::UciControlPacket, UCIMajorVersion, bool),
     ) -> Result<Self, Self::Error> {
         let packet = pair.0;
         let uci_fira_major_ver = pair.1;
+        let is_multicast_list_ntf_v2_supported = pair.2;
         match packet.specialize() {
             uwb_uci_packets::UciControlPacketChild::UciResponse(evt) => {
                 Ok(UciMessage::Response(evt.try_into()?))
             }
             uwb_uci_packets::UciControlPacketChild::UciNotification(evt) => {
-                Ok(UciMessage::Notification((evt, uci_fira_major_ver).try_into()?))
+                Ok(UciMessage::Notification(
+                    (evt, uci_fira_major_ver, is_multicast_list_ntf_v2_supported).try_into()?,
+                ))
             }
             _ => {
                 error!("Unknown packet for converting to UciMessage: {:?}", packet);
diff --git a/src/rust/uwb_core/src/uci/mock_uci_manager.rs b/src/rust/uwb_core/src/uci/mock_uci_manager.rs
index 6dd222f..7ae33ab 100644
--- a/src/rust/uwb_core/src/uci/mock_uci_manager.rs
+++ b/src/rust/uwb_core/src/uci/mock_uci_manager.rs
@@ -839,6 +839,7 @@
         session_id: SessionId,
         action: UpdateMulticastListAction,
         controlees: Controlees,
+        _is_multicast_list_ntf_v2_supported: bool,
     ) -> Result<()> {
         let mut expected_calls = self.expected_calls.lock().unwrap();
         match expected_calls.pop_front() {
diff --git a/src/rust/uwb_core/src/uci/notification.rs b/src/rust/uwb_core/src/uci/notification.rs
index 41c4002..58e68cd 100644
--- a/src/rust/uwb_core/src/uci/notification.rs
+++ b/src/rust/uwb_core/src/uci/notification.rs
@@ -342,20 +342,21 @@
     }
 }
 
-impl TryFrom<(uwb_uci_packets::UciNotification, UCIMajorVersion)> for UciNotification {
+impl TryFrom<(uwb_uci_packets::UciNotification, UCIMajorVersion, bool)> for UciNotification {
     type Error = Error;
     fn try_from(
-        pair: (uwb_uci_packets::UciNotification, UCIMajorVersion),
+        pair: (uwb_uci_packets::UciNotification, UCIMajorVersion, bool),
     ) -> std::result::Result<Self, Self::Error> {
         use uwb_uci_packets::UciNotificationChild;
         let evt = pair.0;
         let uci_fira_major_ver = pair.1;
+        let is_multicast_list_ntf_v2_supported = pair.2;
 
         match evt.specialize() {
             UciNotificationChild::CoreNotification(evt) => Ok(Self::Core(evt.try_into()?)),
-            UciNotificationChild::SessionConfigNotification(evt) => {
-                Ok(Self::Session((evt, uci_fira_major_ver).try_into()?))
-            }
+            UciNotificationChild::SessionConfigNotification(evt) => Ok(Self::Session(
+                (evt, uci_fira_major_ver, is_multicast_list_ntf_v2_supported).try_into()?,
+            )),
             UciNotificationChild::SessionControlNotification(evt) => {
                 Ok(Self::Session(evt.try_into()?))
             }
@@ -391,16 +392,17 @@
     }
 }
 
-impl TryFrom<(uwb_uci_packets::SessionConfigNotification, UCIMajorVersion)>
+impl TryFrom<(uwb_uci_packets::SessionConfigNotification, UCIMajorVersion, bool)>
     for SessionNotification
 {
     type Error = Error;
     fn try_from(
-        pair: (uwb_uci_packets::SessionConfigNotification, UCIMajorVersion),
+        pair: (uwb_uci_packets::SessionConfigNotification, UCIMajorVersion, bool),
     ) -> std::result::Result<Self, Self::Error> {
         use uwb_uci_packets::SessionConfigNotificationChild;
         let evt = pair.0;
         let uci_fira_major_ver = pair.1;
+        let is_multicast_list_ntf_v2_supported = pair.2;
         match evt.specialize() {
             SessionConfigNotificationChild::SessionStatusNtf(evt) => Ok(Self::Status {
                 //no sessionId recieved, assign from sessionIdToToken map in uci_manager
@@ -410,7 +412,8 @@
                 reason_code: evt.get_reason_code(),
             }),
             SessionConfigNotificationChild::SessionUpdateControllerMulticastListNtf(evt)
-                if uci_fira_major_ver == UCIMajorVersion::V1 =>
+                if uci_fira_major_ver == UCIMajorVersion::V1
+                    || !is_multicast_list_ntf_v2_supported =>
             {
                 let payload = evt.get_payload();
                 let multicast_update_list_payload_v1 =
@@ -943,9 +946,12 @@
         let session_notification_packet =
             uwb_uci_packets::SessionConfigNotification::try_from(session_status_ntf).unwrap();
         let uci_fira_major_version = UCIMajorVersion::V1;
-        let session_notification =
-            SessionNotification::try_from((session_notification_packet, uci_fira_major_version))
-                .unwrap();
+        let session_notification = SessionNotification::try_from((
+            session_notification_packet,
+            uci_fira_major_version,
+            false,
+        ))
+        .unwrap();
         let uci_notification_from_session_status_ntf =
             UciNotification::Session(session_notification);
         assert_eq!(
@@ -1029,9 +1035,12 @@
         )
         .unwrap();
         let uci_fira_major_version = UCIMajorVersion::V1;
-        let session_notification =
-            SessionNotification::try_from((session_notification_packet, uci_fira_major_version))
-                .unwrap();
+        let session_notification = SessionNotification::try_from((
+            session_notification_packet,
+            uci_fira_major_version,
+            false,
+        ))
+        .unwrap();
         let uci_notification_from_session_update_controller_multicast_list_ntf =
             UciNotification::Session(session_notification);
         assert_eq!(
@@ -1070,8 +1079,11 @@
         )
         .unwrap();
         let uci_fira_major_version = UCIMajorVersion::V1;
-        let session_notification =
-            SessionNotification::try_from((session_notification_packet, uci_fira_major_version));
+        let session_notification = SessionNotification::try_from((
+            session_notification_packet,
+            uci_fira_major_version,
+            false,
+        ));
         assert_eq!(session_notification, Err(Error::BadParameters));
     }
 
@@ -1099,8 +1111,11 @@
         )
         .unwrap();
         let uci_fira_major_version = UCIMajorVersion::V2;
-        let session_notification =
-            SessionNotification::try_from((session_notification_packet, uci_fira_major_version));
+        let session_notification = SessionNotification::try_from((
+            session_notification_packet,
+            uci_fira_major_version,
+            true,
+        ));
         assert_eq!(session_notification, Err(Error::BadParameters));
     }
 
@@ -1134,9 +1149,12 @@
         )
         .unwrap();
         let uci_fira_major_version = UCIMajorVersion::V2;
-        let session_notification =
-            SessionNotification::try_from((session_notification_packet, uci_fira_major_version))
-                .unwrap();
+        let session_notification = SessionNotification::try_from((
+            session_notification_packet,
+            uci_fira_major_version,
+            true,
+        ))
+        .unwrap();
         let uci_notification_from_session_update_controller_multicast_list_ntf =
             UciNotification::Session(session_notification);
         assert_eq!(
@@ -1161,9 +1179,12 @@
         )
         .unwrap();
         let uci_fira_major_version = UCIMajorVersion::V1;
-        let session_notification =
-            SessionNotification::try_from((session_notification_packet, uci_fira_major_version))
-                .unwrap();
+        let session_notification = SessionNotification::try_from((
+            session_notification_packet,
+            uci_fira_major_version,
+            false,
+        ))
+        .unwrap();
         let uci_notification_from_session_data_transfer_phase_config_ntf =
             UciNotification::Session(session_notification);
         assert_eq!(
@@ -1323,26 +1344,33 @@
         let uci_notification_from_vendor_9 = UciNotification::try_from((
             vendor_9_empty_notification,
             uci_fira_major_version.clone(),
+            false,
         ))
         .unwrap();
         let uci_notification_from_vendor_A = UciNotification::try_from((
             vendor_A_nonempty_notification,
             uci_fira_major_version.clone(),
+            false,
         ))
         .unwrap();
         let uci_notification_from_vendor_B = UciNotification::try_from((
             vendor_B_nonempty_notification,
             uci_fira_major_version.clone(),
+            false,
         ))
         .unwrap();
         let uci_notification_from_vendor_E = UciNotification::try_from((
             vendor_E_nonempty_notification,
             uci_fira_major_version.clone(),
+            false,
         ))
         .unwrap();
-        let uci_notification_from_vendor_F =
-            UciNotification::try_from((vendor_F_nonempty_notification, uci_fira_major_version))
-                .unwrap();
+        let uci_notification_from_vendor_F = UciNotification::try_from((
+            vendor_F_nonempty_notification,
+            uci_fira_major_version,
+            false,
+        ))
+        .unwrap();
         assert_eq!(
             uci_notification_from_vendor_9,
             UciNotification::Vendor(RawUciMessage {
@@ -1391,7 +1419,7 @@
             uwb_uci_packets::TestNotificationBuilder { opcode: 0x22, payload: None }.build().into();
         let uci_fira_major_version = UCIMajorVersion::V1;
         let test_uci_notification =
-            UciNotification::try_from((test_notification, uci_fira_major_version)).unwrap();
+            UciNotification::try_from((test_notification, uci_fira_major_version, false)).unwrap();
         assert_eq!(
             test_uci_notification,
             UciNotification::Vendor(RawUciMessage {
diff --git a/src/rust/uwb_core/src/uci/uci_manager.rs b/src/rust/uwb_core/src/uci/uci_manager.rs
index c811168..fcbb921 100644
--- a/src/rust/uwb_core/src/uci/uci_manager.rs
+++ b/src/rust/uwb_core/src/uci/uci_manager.rs
@@ -121,6 +121,7 @@
         session_id: SessionId,
         action: UpdateMulticastListAction,
         controlees: Controlees,
+        is_multicast_list_ntf_v2_supported: bool,
     ) -> Result<()>;
 
     // Update ranging rounds for DT Tag
@@ -470,6 +471,7 @@
         session_id: SessionId,
         action: UpdateMulticastListAction,
         controlees: Controlees,
+        is_multicast_list_ntf_v2_supported: bool,
     ) -> Result<()> {
         let controlees_len = match controlees {
             Controlees::NoSessionKey(ref controlee_vec) => controlee_vec.len(),
@@ -484,6 +486,7 @@
             session_token: self.get_session_token(&session_id).await?,
             action,
             controlees,
+            is_multicast_list_ntf_v2_supported,
         };
         match self.send_cmd(UciManagerCmd::SendUciCommand { cmd }).await {
             Ok(UciResponse::SessionUpdateControllerMulticastList(resp)) => resp,
@@ -787,6 +790,9 @@
     // DATA_MSG_SEND packets (from Host to UWBS), larger than this should be fragmented into
     // multiple packets with this as the payload size.
     max_data_packet_payload_size: usize,
+
+    // The flag that indicate whether multicast list ntf v2 is supported.
+    is_multicast_list_ntf_v2_supported: bool,
 }
 
 impl<T: UciHal, U: UciLogger> UciManagerActor<T, U> {
@@ -824,6 +830,7 @@
             session_id_to_token_map,
             get_device_info_rsp: None,
             max_data_packet_payload_size: MAX_DATA_PACKET_PAYLOAD_SIZE,
+            is_multicast_list_ntf_v2_supported: false,
         }
     }
 
@@ -1078,6 +1085,16 @@
                     });
                 }
 
+                if let UciCommand::SessionUpdateControllerMulticastList {
+                    session_token: _,
+                    action: _,
+                    controlees: _,
+                    is_multicast_list_ntf_v2_supported,
+                } = cmd.clone()
+                {
+                    self.is_multicast_list_ntf_v2_supported = is_multicast_list_ntf_v2_supported;
+                }
+
                 self.uci_cmd_retryer =
                     Some(UciCmdRetryer { cmd, result_sender, retry_count: MAX_RETRY_COUNT });
 
@@ -1281,6 +1298,7 @@
                     packet,
                     UCIMajorVersion::from_u8(uci_fira_major_version)
                         .map_or(UCIMajorVersion::V1, |v| v),
+                    self.is_multicast_list_ntf_v2_supported,
                 )
                     .try_into()
                 {
@@ -2551,6 +2569,7 @@
                     session_token,
                     action,
                     controlees: Controlees::NoSessionKey(vec![controlee_clone]),
+                    is_multicast_list_ntf_v2_supported: false,
                 };
                 let resp = into_uci_hal_packets(
                     uwb_uci_packets::SessionUpdateControllerMulticastListRspBuilder {
@@ -2572,6 +2591,7 @@
                 session_id,
                 action,
                 uwb_uci_packets::Controlees::NoSessionKey(vec![controlee]),
+                false,
             )
             .await;
         assert!(result.is_ok());
@@ -2600,6 +2620,7 @@
                     session_token,
                     action,
                     controlees: Controlees::ShortSessionKey(vec![controlee_clone]),
+                    is_multicast_list_ntf_v2_supported: true,
                 };
                 let resp = into_uci_hal_packets(
                     uwb_uci_packets::SessionUpdateControllerMulticastListRspBuilder {
@@ -2621,6 +2642,7 @@
                 session_id,
                 action,
                 uwb_uci_packets::Controlees::ShortSessionKey(vec![controlee]),
+                true,
             )
             .await;
         assert!(result.is_ok());
@@ -2650,6 +2672,7 @@
                     session_token,
                     action,
                     controlees: Controlees::LongSessionKey(vec![controlee_clone]),
+                    is_multicast_list_ntf_v2_supported: true,
                 };
                 let resp = into_uci_hal_packets(
                     uwb_uci_packets::SessionUpdateControllerMulticastListRspBuilder {
@@ -2671,6 +2694,7 @@
                 session_id,
                 action,
                 uwb_uci_packets::Controlees::LongSessionKey(vec![controlee]),
+                true,
             )
             .await;
         assert!(result.is_ok());
diff --git a/src/rust/uwb_core/src/uci/uci_manager_sync.rs b/src/rust/uwb_core/src/uci/uci_manager_sync.rs
index 0375f97..53e47d9 100644
--- a/src/rust/uwb_core/src/uci/uci_manager_sync.rs
+++ b/src/rust/uwb_core/src/uci/uci_manager_sync.rs
@@ -316,11 +316,14 @@
         session_id: SessionId,
         action: UpdateMulticastListAction,
         controlees: Controlees,
+        is_multicast_list_ntf_v2_supported: bool,
     ) -> Result<()> {
-        self.runtime_handle.block_on(
-            self.uci_manager
-                .session_update_controller_multicast_list(session_id, action, controlees),
-        )
+        self.runtime_handle.block_on(self.uci_manager.session_update_controller_multicast_list(
+            session_id,
+            action,
+            controlees,
+            is_multicast_list_ntf_v2_supported,
+        ))
     }
 
     /// Update ranging rounds for DT Tag