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

Commit 2725d798 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Exclude Duo audio calls from the new call log."

parents df466330 6d119a10
Loading
Loading
Loading
Loading
+124 −95
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ import com.android.dialer.common.Assert;
import com.android.dialer.common.LogUtil;
import com.android.dialer.common.concurrent.Annotations.BackgroundExecutor;
import com.android.dialer.compat.android.provider.VoicemailCompat;
import com.android.dialer.duo.DuoConstants;
import com.android.dialer.inject.ApplicationContext;
import com.android.dialer.phonenumberproto.DialerPhoneNumberUtil;
import com.android.dialer.storage.Unencrypted;
@@ -277,12 +278,16 @@ public class SystemCallLogDataSource implements CallLogDataSource {
        return;
      }

      if (!cursor.moveToFirst()) {
        LogUtil.i("SystemCallLogDataSource.handleInsertsAndUpdates", "no entries to insert/update");
        return;
      }

      LogUtil.i(
          "SystemCallLogDataSource.handleInsertsAndUpdates",
          "found %d entries to insert/update",
          cursor.getCount());

      if (cursor.moveToFirst()) {
      int idColumn = cursor.getColumnIndexOrThrow(Calls._ID);
      int dateColumn = cursor.getColumnIndexOrThrow(Calls.DATE);
      int lastModifiedColumn = cursor.getColumnIndexOrThrow(Calls.LAST_MODIFIED);
@@ -335,6 +340,11 @@ public class SystemCallLogDataSource implements CallLogDataSource {
        int features = cursor.getInt(featuresColumn);
        String postDialDigits = cursor.getString(postDialDigitsColumn);

        // Exclude Duo audio calls.
        if (isDuoAudioCall(phoneAccountComponentName, features)) {
          continue;
        }

        ContentValues contentValues = new ContentValues();
        contentValues.put(AnnotatedCallLog.TIMESTAMP, date);

@@ -360,8 +370,7 @@ public class SystemCallLogDataSource implements CallLogDataSource {
        contentValues.put(AnnotatedCallLog.IS_READ, isRead);
        contentValues.put(AnnotatedCallLog.NEW, isNew);
        contentValues.put(AnnotatedCallLog.GEOCODED_LOCATION, geocodedLocation);
          contentValues.put(
              AnnotatedCallLog.PHONE_ACCOUNT_COMPONENT_NAME, phoneAccountComponentName);
        contentValues.put(AnnotatedCallLog.PHONE_ACCOUNT_COMPONENT_NAME, phoneAccountComponentName);
        contentValues.put(AnnotatedCallLog.PHONE_ACCOUNT_ID, phoneAccountId);
        populatePhoneAccountLabelAndColor(
            appContext, contentValues, phoneAccountComponentName, phoneAccountId);
@@ -378,10 +387,30 @@ public class SystemCallLogDataSource implements CallLogDataSource {
          mutations.insert(id, contentValues);
        }
      } while (cursor.moveToNext());
      } // else no new results, do nothing.
    }
  }

  /**
   * Returns true if the phone account component name and the features belong to a Duo audio call.
   *
   * <p>Characteristics of a Duo audio call are as follows.
   *
   * <ul>
   *   <li>The phone account component name is {@link DuoConstants#PHONE_ACCOUNT_COMPONENT_NAME};
   *       and
   *   <li>The features don't include {@link Calls#FEATURES_VIDEO}.
   * </ul>
   *
   * <p>It is the caller's responsibility to ensure the phone account component name and the
   * features come from the same call log entry.
   */
  private static boolean isDuoAudioCall(@Nullable String phoneAccountComponentName, int features) {
    return DuoConstants.PHONE_ACCOUNT_COMPONENT_NAME
            .flattenToString()
            .equals(phoneAccountComponentName)
        && ((features & Calls.FEATURES_VIDEO) != Calls.FEATURES_VIDEO);
  }

  private void setTranscriptionState(Cursor cursor, ContentValues contentValues) {
    if (VERSION.SDK_INT >= VERSION_CODES.O) {
      int transcriptionStateColumn =