Loading android/app/src/com/android/bluetooth/content_profiles/ContentProfileErrorReportUtils.java +6 −7 Original line number Diff line number Diff line Loading @@ -34,9 +34,6 @@ public class ContentProfileErrorReportUtils { /* Minimum period between two error reports */ @VisibleForTesting static final long MIN_PERIOD_BETWEEN_TWO_ERROR_REPORTS_MILLIS = 1_000; /* Whether reporting is enabled by flags */ @VisibleForTesting static boolean sEnabled = Flags.contentProfilesErrorsMetrics(); @VisibleForTesting static long sLastReportTime = 0; /** Loading @@ -52,10 +49,11 @@ public class ContentProfileErrorReportUtils { * BluetoothStatsLog#BLUETOOTH_CONTENT_PROFILE_ERROR_REPORTED__TYPE__LOG_WARN} * @param tag A tag which represents the code location of this error. The values are managed per * each java file. * @return true if successfully wrote the error, false otherwise */ public static synchronized void report(int profile, int fileNameEnum, int type, int tag) { if (!sEnabled) { return; public static synchronized boolean report(int profile, int fileNameEnum, int type, int tag) { if (!Flags.contentProfilesErrorsMetrics()) { return false; } if (isTooFrequentReport()) { Loading @@ -66,7 +64,7 @@ public class ContentProfileErrorReportUtils { + fileNameEnum + ", tag=" + tag); return; return false; } BluetoothStatsLog.write( Loading @@ -76,6 +74,7 @@ public class ContentProfileErrorReportUtils { type, tag); sLastReportTime = SystemClock.uptimeMillis(); return true; } private static boolean isTooFrequentReport() { Loading android/app/tests/unit/src/com/android/bluetooth/content_profiles/ContentProfileErrorReportUtilsTest.java +3 −6 Original line number Diff line number Diff line Loading @@ -40,8 +40,7 @@ public class ContentProfileErrorReportUtilsTest { mSetFlagsRule.disableFlags(Flags.FLAG_CONTENT_PROFILES_ERRORS_METRICS); long previousReportTimeMillis = ContentProfileErrorReportUtils.sLastReportTime; ContentProfileErrorReportUtils.report(0, 0, 0, 0); assertThat(ContentProfileErrorReportUtils.report(0, 0, 0, 0)).isFalse(); // The last report time should not be changed. assertThat(ContentProfileErrorReportUtils.sLastReportTime) .isEqualTo(previousReportTimeMillis); Loading @@ -54,8 +53,7 @@ public class ContentProfileErrorReportUtilsTest { long lastReportTimeMillisToSet = SystemClock.uptimeMillis(); ContentProfileErrorReportUtils.sLastReportTime = lastReportTimeMillisToSet; ContentProfileErrorReportUtils.report(0, 0, 0, 0); assertThat(ContentProfileErrorReportUtils.report(0, 0, 0, 0)).isFalse(); // The last report time should not be changed. assertThat(ContentProfileErrorReportUtils.sLastReportTime) .isEqualTo(lastReportTimeMillisToSet); Loading @@ -72,8 +70,7 @@ public class ContentProfileErrorReportUtilsTest { * 2); ContentProfileErrorReportUtils.sLastReportTime = lastReportTimeMillisToSet; ContentProfileErrorReportUtils.report(0, 0, 0, 0); assertThat(ContentProfileErrorReportUtils.report(0, 0, 0, 0)).isTrue(); // After the successful report, the last report time should be changed. assertThat(ContentProfileErrorReportUtils.sLastReportTime) .isGreaterThan(lastReportTimeMillisToSet); Loading Loading
android/app/src/com/android/bluetooth/content_profiles/ContentProfileErrorReportUtils.java +6 −7 Original line number Diff line number Diff line Loading @@ -34,9 +34,6 @@ public class ContentProfileErrorReportUtils { /* Minimum period between two error reports */ @VisibleForTesting static final long MIN_PERIOD_BETWEEN_TWO_ERROR_REPORTS_MILLIS = 1_000; /* Whether reporting is enabled by flags */ @VisibleForTesting static boolean sEnabled = Flags.contentProfilesErrorsMetrics(); @VisibleForTesting static long sLastReportTime = 0; /** Loading @@ -52,10 +49,11 @@ public class ContentProfileErrorReportUtils { * BluetoothStatsLog#BLUETOOTH_CONTENT_PROFILE_ERROR_REPORTED__TYPE__LOG_WARN} * @param tag A tag which represents the code location of this error. The values are managed per * each java file. * @return true if successfully wrote the error, false otherwise */ public static synchronized void report(int profile, int fileNameEnum, int type, int tag) { if (!sEnabled) { return; public static synchronized boolean report(int profile, int fileNameEnum, int type, int tag) { if (!Flags.contentProfilesErrorsMetrics()) { return false; } if (isTooFrequentReport()) { Loading @@ -66,7 +64,7 @@ public class ContentProfileErrorReportUtils { + fileNameEnum + ", tag=" + tag); return; return false; } BluetoothStatsLog.write( Loading @@ -76,6 +74,7 @@ public class ContentProfileErrorReportUtils { type, tag); sLastReportTime = SystemClock.uptimeMillis(); return true; } private static boolean isTooFrequentReport() { Loading
android/app/tests/unit/src/com/android/bluetooth/content_profiles/ContentProfileErrorReportUtilsTest.java +3 −6 Original line number Diff line number Diff line Loading @@ -40,8 +40,7 @@ public class ContentProfileErrorReportUtilsTest { mSetFlagsRule.disableFlags(Flags.FLAG_CONTENT_PROFILES_ERRORS_METRICS); long previousReportTimeMillis = ContentProfileErrorReportUtils.sLastReportTime; ContentProfileErrorReportUtils.report(0, 0, 0, 0); assertThat(ContentProfileErrorReportUtils.report(0, 0, 0, 0)).isFalse(); // The last report time should not be changed. assertThat(ContentProfileErrorReportUtils.sLastReportTime) .isEqualTo(previousReportTimeMillis); Loading @@ -54,8 +53,7 @@ public class ContentProfileErrorReportUtilsTest { long lastReportTimeMillisToSet = SystemClock.uptimeMillis(); ContentProfileErrorReportUtils.sLastReportTime = lastReportTimeMillisToSet; ContentProfileErrorReportUtils.report(0, 0, 0, 0); assertThat(ContentProfileErrorReportUtils.report(0, 0, 0, 0)).isFalse(); // The last report time should not be changed. assertThat(ContentProfileErrorReportUtils.sLastReportTime) .isEqualTo(lastReportTimeMillisToSet); Loading @@ -72,8 +70,7 @@ public class ContentProfileErrorReportUtilsTest { * 2); ContentProfileErrorReportUtils.sLastReportTime = lastReportTimeMillisToSet; ContentProfileErrorReportUtils.report(0, 0, 0, 0); assertThat(ContentProfileErrorReportUtils.report(0, 0, 0, 0)).isTrue(); // After the successful report, the last report time should be changed. assertThat(ContentProfileErrorReportUtils.sLastReportTime) .isGreaterThan(lastReportTimeMillisToSet); Loading