Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1661af6b authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 9416697 from 90feee59 to tm-qpr2-release

Change-Id: Ie36ec46d8ffa590fb11214513e0a768de294caa6
parents 91d259ed 90feee59
Loading
Loading
Loading
Loading
+12 −4
Original line number Original line Diff line number Diff line
@@ -1420,6 +1420,7 @@ public class BluetoothMapContentObserver {
                        int type = c.getInt(c.getColumnIndex(Sms.TYPE));
                        int type = c.getInt(c.getColumnIndex(Sms.TYPE));
                        int threadId = c.getInt(c.getColumnIndex(Sms.THREAD_ID));
                        int threadId = c.getInt(c.getColumnIndex(Sms.THREAD_ID));
                        int read = c.getInt(c.getColumnIndex(Sms.READ));
                        int read = c.getInt(c.getColumnIndex(Sms.READ));
                        long timestamp = c.getLong(c.getColumnIndex(Sms.DATE));


                        Msg msg = getMsgListSms().remove(id);
                        Msg msg = getMsgListSms().remove(id);


@@ -1427,6 +1428,10 @@ public class BluetoothMapContentObserver {
                         * a message deleted and/or MessageShift for messages deleted by the MCE. */
                         * a message deleted and/or MessageShift for messages deleted by the MCE. */


                        if (msg == null) {
                        if (msg == null) {
                            if (BluetoothMapUtils.isDateTimeOlderThanOneYear(timestamp)) {
                                // Skip sending new message events older than one year
                                continue;
                            }
                            /* New message */
                            /* New message */
                            msg = new Msg(id, type, threadId, read);
                            msg = new Msg(id, type, threadId, read);
                            msgListSms.put(id, msg);
                            msgListSms.put(id, msg);
@@ -1435,8 +1440,7 @@ public class BluetoothMapContentObserver {
                            if (mTransmitEvents && // extract contact details only if needed
                            if (mTransmitEvents && // extract contact details only if needed
                                    mMapEventReportVersion
                                    mMapEventReportVersion
                                            > BluetoothMapUtils.MAP_EVENT_REPORT_V10) {
                                            > BluetoothMapUtils.MAP_EVENT_REPORT_V10) {
                                String date = BluetoothMapUtils.getDateTimeString(
                                String date = BluetoothMapUtils.getDateTimeString(timestamp);
                                        c.getLong(c.getColumnIndex(Sms.DATE)));
                                String subject = c.getString(c.getColumnIndex(Sms.BODY));
                                String subject = c.getString(c.getColumnIndex(Sms.BODY));
                                if (subject == null) {
                                if (subject == null) {
                                    subject = "";
                                    subject = "";
@@ -1583,6 +1587,7 @@ public class BluetoothMapContentObserver {
                        // TODO: Go through code to see if we have an issue with mismatch in types
                        // TODO: Go through code to see if we have an issue with mismatch in types
                        //       for threadId. Seems to be a long in DB??
                        //       for threadId. Seems to be a long in DB??
                        int read = c.getInt(c.getColumnIndex(Mms.READ));
                        int read = c.getInt(c.getColumnIndex(Mms.READ));
                        long timestamp = c.getLong(c.getColumnIndex(Mms.DATE));


                        Msg msg = getMsgListMms().remove(id);
                        Msg msg = getMsgListMms().remove(id);


@@ -1591,6 +1596,10 @@ public class BluetoothMapContentObserver {
                         * MCE.*/
                         * MCE.*/


                        if (msg == null) {
                        if (msg == null) {
                            if (BluetoothMapUtils.isDateTimeOlderThanOneYear(timestamp)) {
                                // Skip sending new message events older than one year
                                continue;
                            }
                            /* New message - only notify on retrieve conf */
                            /* New message - only notify on retrieve conf */
                            listChanged = true;
                            listChanged = true;
                            if (getMmsFolderName(type).equalsIgnoreCase(
                            if (getMmsFolderName(type).equalsIgnoreCase(
@@ -1604,8 +1613,7 @@ public class BluetoothMapContentObserver {
                            if (mTransmitEvents && // extract contact details only if needed
                            if (mTransmitEvents && // extract contact details only if needed
                                    mMapEventReportVersion
                                    mMapEventReportVersion
                                            != BluetoothMapUtils.MAP_EVENT_REPORT_V10) {
                                            != BluetoothMapUtils.MAP_EVENT_REPORT_V10) {
                                String date = BluetoothMapUtils.getDateTimeString(
                                String date = BluetoothMapUtils.getDateTimeString(timestamp);
                                        c.getLong(c.getColumnIndex(Mms.DATE)));
                                String subject = c.getString(c.getColumnIndex(Mms.SUBJECT));
                                String subject = c.getString(c.getColumnIndex(Mms.SUBJECT));
                                if (subject == null || subject.length() == 0) {
                                if (subject == null || subject.length() == 0) {
                                    /* Get subject from mms text body parts - if any exists */
                                    /* Get subject from mms text body parts - if any exists */
+15 −0
Original line number Original line Diff line number Diff line
@@ -677,6 +677,21 @@ public class BluetoothMapUtils {
        return format.format(cal.getTime());
        return format.format(cal.getTime());
    }
    }


    static boolean isDateTimeOlderThanOneYear(long timestamp) {
        Calendar cal = Calendar.getInstance();
        cal.setTimeInMillis(timestamp);
        Calendar oneYearAgo = Calendar.getInstance();
        oneYearAgo.add(Calendar.YEAR, -1);
        if (cal.compareTo(oneYearAgo) > 0) {
            if (V) {
                Log.v(TAG, "isDateTimeOlderThanOneYear timestamp : " + timestamp
                        + " oneYearAgo: " + oneYearAgo);
            }
            return true;
        }
        return false;
    }

    static void savePeerSupportUtcTimeStamp(int remoteFeatureMask) {
    static void savePeerSupportUtcTimeStamp(int remoteFeatureMask) {
        if ((remoteFeatureMask & MAP_FEATURE_DEFINED_TIMESTAMP_FORMAT_BIT)
        if ((remoteFeatureMask & MAP_FEATURE_DEFINED_TIMESTAMP_FORMAT_BIT)
                == MAP_FEATURE_DEFINED_TIMESTAMP_FORMAT_BIT) {
                == MAP_FEATURE_DEFINED_TIMESTAMP_FORMAT_BIT) {
+39 −2
Original line number Original line Diff line number Diff line
@@ -280,6 +280,19 @@ class LeAudioClientImpl : public LeAudioClient {
      return;
      return;
    }
    }


    /* For sonification events we don't really need to reconfigure to HQ
     * configuration, but if the previous configuration was for HQ Media,
     * we might want to go back to that scenario.
     */

    if ((configuration_context_type_ != LeAudioContextType::MEDIA) &&
        (configuration_context_type_ != LeAudioContextType::GAME)) {
      LOG_INFO(
          "Keeping the old configuration as no HQ Media playback is needed "
          "right now.");
      return;
    }

    /* Test the existing metadata against the recent availability */
    /* Test the existing metadata against the recent availability */
    metadata_context_types_.sink &= group->GetAvailableContexts();
    metadata_context_types_.sink &= group->GetAvailableContexts();
    if (metadata_context_types_.sink.none()) {
    if (metadata_context_types_.sink.none()) {
@@ -735,14 +748,15 @@ class LeAudioClientImpl : public LeAudioClient {
          /* Highest priority first */
          /* Highest priority first */
          LeAudioContextType::CONVERSATIONAL,
          LeAudioContextType::CONVERSATIONAL,
          LeAudioContextType::RINGTONE,
          LeAudioContextType::RINGTONE,
          LeAudioContextType::GAME,
          LeAudioContextType::LIVE,
          LeAudioContextType::LIVE,
          LeAudioContextType::VOICEASSISTANTS,
          LeAudioContextType::VOICEASSISTANTS,
          LeAudioContextType::GAME,
          LeAudioContextType::MEDIA,
          LeAudioContextType::MEDIA,
          LeAudioContextType::EMERGENCYALARM,
          LeAudioContextType::EMERGENCYALARM,
          LeAudioContextType::ALERTS,
          LeAudioContextType::ALERTS,
          LeAudioContextType::INSTRUCTIONAL,
          LeAudioContextType::INSTRUCTIONAL,
          LeAudioContextType::NOTIFICATIONS,
          LeAudioContextType::NOTIFICATIONS,
          LeAudioContextType::SOUNDEFFECTS,
      };
      };
      for (auto ct : context_priority_list) {
      for (auto ct : context_priority_list) {
        if (metadata_context_type.test(ct)) {
        if (metadata_context_type.test(ct)) {
@@ -3495,14 +3509,15 @@ class LeAudioClientImpl : public LeAudioClient {
           * call volume slider while not in a call.
           * call volume slider while not in a call.
           * LeAudioContextType::RINGTONE,
           * LeAudioContextType::RINGTONE,
           */
           */
          LeAudioContextType::GAME,
          LeAudioContextType::LIVE,
          LeAudioContextType::LIVE,
          LeAudioContextType::VOICEASSISTANTS,
          LeAudioContextType::VOICEASSISTANTS,
          LeAudioContextType::GAME,
          LeAudioContextType::MEDIA,
          LeAudioContextType::MEDIA,
          LeAudioContextType::EMERGENCYALARM,
          LeAudioContextType::EMERGENCYALARM,
          LeAudioContextType::ALERTS,
          LeAudioContextType::ALERTS,
          LeAudioContextType::INSTRUCTIONAL,
          LeAudioContextType::INSTRUCTIONAL,
          LeAudioContextType::NOTIFICATIONS,
          LeAudioContextType::NOTIFICATIONS,
          LeAudioContextType::SOUNDEFFECTS,
      };
      };
      for (auto ct : context_priority_list) {
      for (auto ct : context_priority_list) {
        if (available_remote_contexts.test(ct)) {
        if (available_remote_contexts.test(ct)) {
@@ -3655,6 +3670,28 @@ class LeAudioClientImpl : public LeAudioClient {
    auto new_configuration_context =
    auto new_configuration_context =
        ChooseConfigurationContextType(new_metadata_context_types_);
        ChooseConfigurationContextType(new_metadata_context_types_);


    /* For the following contexts we don't actually need HQ audio:
     * LeAudioContextType::NOTIFICATIONS
     * LeAudioContextType::SOUNDEFFECTS
     * LeAudioContextType::INSTRUCTIONAL
     * LeAudioContextType::ALERTS
     * LeAudioContextType::EMERGENCYALARM
     * So do not reconfigure if the remote sink is already available at any
     * quality and these are the only contributors to the current audio stream.
     */
    auto no_reconfigure_contexts =
        LeAudioContextType::NOTIFICATIONS | LeAudioContextType::SOUNDEFFECTS |
        LeAudioContextType::INSTRUCTIONAL | LeAudioContextType::ALERTS |
        LeAudioContextType::EMERGENCYALARM;
    if ((new_metadata_context_types_ & ~no_reconfigure_contexts).none() &&
        IsDirectionAvailableForCurrentConfiguration(
            group, le_audio::types::kLeAudioDirectionSink)) {
      LOG_INFO(
          "There is no need to reconfigure for the sonification events. Keep "
          "the configuration unchanged.");
      new_configuration_context = configuration_context_type_;
    }

    LOG_DEBUG("new_configuration_context= %s",
    LOG_DEBUG("new_configuration_context= %s",
              ToString(new_configuration_context).c_str());
              ToString(new_configuration_context).c_str());
    ReconfigureOrUpdateMetadata(group, new_configuration_context,
    ReconfigureOrUpdateMetadata(group, new_configuration_context,
+17 −9
Original line number Original line Diff line number Diff line
@@ -1478,8 +1478,18 @@ bool LeAudioDevice::ConfigureAses(
    types::AudioLocations& group_src_audio_locations, bool reuse_cis_id,
    types::AudioLocations& group_src_audio_locations, bool reuse_cis_id,
    AudioContexts metadata_context_type,
    AudioContexts metadata_context_type,
    const std::vector<uint8_t>& ccid_list) {
    const std::vector<uint8_t>& ccid_list) {
  struct ase* ase = GetFirstInactiveAse(ent.direction, reuse_cis_id);
  /* First try to use the already configured ASE */
  if (!ase) return false;
  auto ase = GetFirstActiveAseByDirection(ent.direction);
  if (ase) {
    LOG_INFO("Using an already active ASE id=%d", ase->id);
  } else {
    ase = GetFirstInactiveAse(ent.direction, reuse_cis_id);
  }

  if (!ase) {
    LOG_ERROR("Unable to find an ASE to configure");
    return false;
  }


  uint8_t active_ases = *number_of_already_active_group_ase;
  uint8_t active_ases = *number_of_already_active_group_ase;
  uint8_t max_required_ase_per_dev =
  uint8_t max_required_ase_per_dev =
@@ -1551,8 +1561,12 @@ bool LeAudioDevice::ConfigureAses(
        (ent.direction == 1 ? "snk" : "src"), ase->max_sdu_size, ase->cis_id,
        (ent.direction == 1 ? "snk" : "src"), ase->max_sdu_size, ase->cis_id,
        ent.target_latency);
        ent.target_latency);


    /* Try to use the already active ASE */
    ase = GetNextActiveAseWithSameDirection(ase);
    if (ase == nullptr) {
      ase = GetFirstInactiveAse(ent.direction, reuse_cis_id);
      ase = GetFirstInactiveAse(ent.direction, reuse_cis_id);
    }
    }
  }


  *number_of_already_active_group_ase = active_ases;
  *number_of_already_active_group_ase = active_ases;
  return true;
  return true;
@@ -1603,12 +1617,6 @@ bool LeAudioDeviceGroup::ConfigureAses(
    for (auto* device = GetFirstDeviceWithActiveContext(context_type);
    for (auto* device = GetFirstDeviceWithActiveContext(context_type);
         device != nullptr && required_device_cnt > 0;
         device != nullptr && required_device_cnt > 0;
         device = GetNextDeviceWithActiveContext(device, context_type)) {
         device = GetNextDeviceWithActiveContext(device, context_type)) {
      /* Skip if device has ASE configured in this direction already */
      if (device->GetFirstActiveAseByDirection(ent.direction)) {
        required_device_cnt--;
        continue;
      }

      /* For the moment, we configure only connected devices and when it is
      /* For the moment, we configure only connected devices and when it is
       * ready to stream i.e. All ASEs are discovered and device is reported as
       * ready to stream i.e. All ASEs are discovered and device is reported as
       * connected
       * connected
+21 −9
Original line number Original line Diff line number Diff line
@@ -3440,10 +3440,12 @@ TEST_F(UnicastTest, TwoEarbudsStreamingContextSwitchNoReconfigure) {
  LeAudioClient::Get()->GroupSetActive(group_id);
  LeAudioClient::Get()->GroupSetActive(group_id);
  Mock::VerifyAndClearExpectations(&mock_le_audio_source_hal_client_);
  Mock::VerifyAndClearExpectations(&mock_le_audio_source_hal_client_);


  // Start streaming with reconfiguration from default media stream setup
  // Start streaming with new metadata, but use the existing configuration
  EXPECT_CALL(
  EXPECT_CALL(
      mock_state_machine_,
      mock_state_machine_,
      StartStream(_, le_audio::types::LeAudioContextType::NOTIFICATIONS, _, _))
      StartStream(
          _, types::LeAudioContextType::MEDIA,
          types::AudioContexts(types::LeAudioContextType::NOTIFICATIONS), _))
      .Times(1);
      .Times(1);


  StartStreaming(AUDIO_USAGE_NOTIFICATION, AUDIO_CONTENT_TYPE_UNKNOWN,
  StartStreaming(AUDIO_USAGE_NOTIFICATION, AUDIO_CONTENT_TYPE_UNKNOWN,
@@ -3453,37 +3455,47 @@ TEST_F(UnicastTest, TwoEarbudsStreamingContextSwitchNoReconfigure) {
  Mock::VerifyAndClearExpectations(&mock_le_audio_source_hal_client_);
  Mock::VerifyAndClearExpectations(&mock_le_audio_source_hal_client_);
  SyncOnMainLoop();
  SyncOnMainLoop();


  // Do a content switch to ALERTS
  // Do a metadata content switch to ALERTS but stay on MEDIA configuration
  EXPECT_CALL(*mock_le_audio_source_hal_client_, OnDestroyed()).Times(0);
  EXPECT_CALL(*mock_le_audio_source_hal_client_, OnDestroyed()).Times(0);
  EXPECT_CALL(*mock_le_audio_source_hal_client_, Stop).Times(0);
  EXPECT_CALL(*mock_le_audio_source_hal_client_, Stop).Times(0);
  EXPECT_CALL(*mock_le_audio_source_hal_client_, Start).Times(0);
  EXPECT_CALL(*mock_le_audio_source_hal_client_, Start).Times(0);
  EXPECT_CALL(mock_state_machine_,
  EXPECT_CALL(
              StartStream(_, le_audio::types::LeAudioContextType::ALERTS, _, _))
      mock_state_machine_,
      StartStream(
          _, le_audio::types::LeAudioContextType::MEDIA,
          types::AudioContexts(le_audio::types::LeAudioContextType::ALERTS), _))
      .Times(1);
      .Times(1);
  UpdateMetadata(AUDIO_USAGE_ALARM, AUDIO_CONTENT_TYPE_UNKNOWN);
  UpdateMetadata(AUDIO_USAGE_ALARM, AUDIO_CONTENT_TYPE_UNKNOWN);
  Mock::VerifyAndClearExpectations(&mock_audio_hal_client_callbacks_);
  Mock::VerifyAndClearExpectations(&mock_audio_hal_client_callbacks_);
  Mock::VerifyAndClearExpectations(&mock_le_audio_source_hal_client_);
  Mock::VerifyAndClearExpectations(&mock_le_audio_source_hal_client_);


  // Do a content switch to EMERGENCY
  // Do a metadata content switch to EMERGENCY but stay on MEDIA configuration
  EXPECT_CALL(*mock_le_audio_source_hal_client_, OnDestroyed()).Times(0);
  EXPECT_CALL(*mock_le_audio_source_hal_client_, OnDestroyed()).Times(0);
  EXPECT_CALL(*mock_le_audio_source_hal_client_, Stop).Times(0);
  EXPECT_CALL(*mock_le_audio_source_hal_client_, Stop).Times(0);
  EXPECT_CALL(*mock_le_audio_source_hal_client_, Start).Times(0);
  EXPECT_CALL(*mock_le_audio_source_hal_client_, Start).Times(0);


  EXPECT_CALL(
  EXPECT_CALL(
      mock_state_machine_,
      mock_state_machine_,
      StartStream(_, le_audio::types::LeAudioContextType::EMERGENCYALARM, _, _))
      StartStream(_, le_audio::types::LeAudioContextType::MEDIA,
                  types::AudioContexts(
                      le_audio::types::LeAudioContextType::EMERGENCYALARM),
                  _))
      .Times(1);
      .Times(1);
  UpdateMetadata(AUDIO_USAGE_EMERGENCY, AUDIO_CONTENT_TYPE_UNKNOWN);
  UpdateMetadata(AUDIO_USAGE_EMERGENCY, AUDIO_CONTENT_TYPE_UNKNOWN);
  Mock::VerifyAndClearExpectations(&mock_audio_hal_client_callbacks_);
  Mock::VerifyAndClearExpectations(&mock_audio_hal_client_callbacks_);
  Mock::VerifyAndClearExpectations(&mock_le_audio_source_hal_client_);
  Mock::VerifyAndClearExpectations(&mock_le_audio_source_hal_client_);


  // Do a content switch to INSTRUCTIONAL
  // Do a metadata content switch to INSTRUCTIONAL but stay on MEDIA
  // configuration
  EXPECT_CALL(*mock_le_audio_source_hal_client_, OnDestroyed()).Times(0);
  EXPECT_CALL(*mock_le_audio_source_hal_client_, OnDestroyed()).Times(0);
  EXPECT_CALL(*mock_le_audio_source_hal_client_, Stop).Times(0);
  EXPECT_CALL(*mock_le_audio_source_hal_client_, Stop).Times(0);
  EXPECT_CALL(*mock_le_audio_source_hal_client_, Start).Times(0);
  EXPECT_CALL(*mock_le_audio_source_hal_client_, Start).Times(0);
  EXPECT_CALL(
  EXPECT_CALL(
      mock_state_machine_,
      mock_state_machine_,
      StartStream(_, le_audio::types::LeAudioContextType::INSTRUCTIONAL, _, _))
      StartStream(_, le_audio::types::LeAudioContextType::MEDIA,
                  types::AudioContexts(
                      le_audio::types::LeAudioContextType::INSTRUCTIONAL),
                  _))
      .Times(1);
      .Times(1);
  UpdateMetadata(AUDIO_USAGE_ASSISTANCE_NAVIGATION_GUIDANCE,
  UpdateMetadata(AUDIO_USAGE_ASSISTANCE_NAVIGATION_GUIDANCE,
                 AUDIO_CONTENT_TYPE_UNKNOWN);
                 AUDIO_CONTENT_TYPE_UNKNOWN);
Loading