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

Commit 8c933e82 authored by Hyundo Moon's avatar Hyundo Moon Committed by Gerrit Code Review
Browse files

Merge "Remove content_profiles_errors_metrics flag usages" into main

parents 3aff6467 0b58c5ee
Loading
Loading
Loading
Loading
+1 −7
Original line number Diff line number Diff line
@@ -21,12 +21,10 @@ import android.os.SystemClock;
import android.util.Log;

import com.android.bluetooth.BluetoothStatsLog;
import com.android.bluetooth.flags.Flags;
import com.android.internal.annotations.VisibleForTesting;

/**
 * Utility method to report exceptions and error/warn logs in content profiles. Will be no-op if
 * {@link Flags#contentProfilesErrorsMetrics()} is not enabled.
 * Utility method to report exceptions and error/warn logs in content profiles.
 */
public class ContentProfileErrorReportUtils {
    private static final String TAG = ContentProfileErrorReportUtils.class.getSimpleName();
@@ -52,10 +50,6 @@ public class ContentProfileErrorReportUtils {
     * @return true if successfully wrote the error, false otherwise
     */
    public static synchronized boolean report(int profile, int fileNameEnum, int type, int tag) {
        if (!Flags.contentProfilesErrorsMetrics()) {
            return false;
        }

        if (isTooFrequentReport()) {
            Log.w(
                    TAG,
+0 −18
Original line number Diff line number Diff line
@@ -18,13 +18,10 @@ package com.android.bluetooth.content_profiles;
import static com.google.common.truth.Truth.assertThat;

import android.os.SystemClock;
import android.platform.test.flag.junit.SetFlagsRule;

import androidx.test.filters.SmallTest;
import androidx.test.runner.AndroidJUnit4;

import com.android.bluetooth.flags.Flags;

import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -33,22 +30,8 @@ import org.junit.runner.RunWith;
@RunWith(AndroidJUnit4.class)
public class ContentProfileErrorReportUtilsTest {

    @Rule public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();

    @Test
    public void noOpWhenFlagIsDisabled() {
        mSetFlagsRule.disableFlags(Flags.FLAG_CONTENT_PROFILES_ERRORS_METRICS);
        long previousReportTimeMillis = ContentProfileErrorReportUtils.sLastReportTime;

        assertThat(ContentProfileErrorReportUtils.report(0, 0, 0, 0)).isFalse();
        // The last report time should not be changed.
        assertThat(ContentProfileErrorReportUtils.sLastReportTime)
                .isEqualTo(previousReportTimeMillis);
    }

    @Test
    public void tooFrequentErrorReportIsSkipped() {
        mSetFlagsRule.enableFlags(Flags.FLAG_CONTENT_PROFILES_ERRORS_METRICS);
        // Set the last report time to the current time.
        long lastReportTimeMillisToSet = SystemClock.uptimeMillis();
        ContentProfileErrorReportUtils.sLastReportTime = lastReportTimeMillisToSet;
@@ -61,7 +44,6 @@ public class ContentProfileErrorReportUtilsTest {

    @Test
    public void successfulReport() {
        mSetFlagsRule.enableFlags(Flags.FLAG_CONTENT_PROFILES_ERRORS_METRICS);
        // Set the last report time to much earlier than the current time.
        long lastReportTimeMillisToSet =
                SystemClock.uptimeMillis()