Loading android/app/src/com/android/bluetooth/content_profiles/ContentProfileErrorReportUtils.java +1 −7 Original line number Diff line number Diff line Loading @@ -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(); Loading @@ -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, Loading android/app/tests/unit/src/com/android/bluetooth/content_profiles/ContentProfileErrorReportUtilsTest.java +0 −18 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading @@ -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() Loading Loading
android/app/src/com/android/bluetooth/content_profiles/ContentProfileErrorReportUtils.java +1 −7 Original line number Diff line number Diff line Loading @@ -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(); Loading @@ -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, Loading
android/app/tests/unit/src/com/android/bluetooth/content_profiles/ContentProfileErrorReportUtilsTest.java +0 −18 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading @@ -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() Loading