Loading android/app/src/com/android/bluetooth/content_profiles/ContentProfileErrorReportUtils.java +1 −7 Original line number Original line Diff line number Diff line Loading @@ -21,12 +21,10 @@ import android.os.SystemClock; import android.util.Log; import android.util.Log; import com.android.bluetooth.BluetoothStatsLog; import com.android.bluetooth.BluetoothStatsLog; import com.android.bluetooth.flags.Flags; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.annotations.VisibleForTesting; /** /** * Utility method to report exceptions and error/warn logs in content profiles. Will be no-op if * Utility method to report exceptions and error/warn logs in content profiles. * {@link Flags#contentProfilesErrorsMetrics()} is not enabled. */ */ public class ContentProfileErrorReportUtils { public class ContentProfileErrorReportUtils { private static final String TAG = ContentProfileErrorReportUtils.class.getSimpleName(); 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 * @return true if successfully wrote the error, false otherwise */ */ public static synchronized boolean report(int profile, int fileNameEnum, int type, int tag) { public static synchronized boolean report(int profile, int fileNameEnum, int type, int tag) { if (!Flags.contentProfilesErrorsMetrics()) { return false; } if (isTooFrequentReport()) { if (isTooFrequentReport()) { Log.w( Log.w( TAG, TAG, Loading android/app/tests/unit/src/com/android/bluetooth/content_profiles/ContentProfileErrorReportUtilsTest.java +0 −18 Original line number Original line 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 static com.google.common.truth.Truth.assertThat; import android.os.SystemClock; import android.os.SystemClock; import android.platform.test.flag.junit.SetFlagsRule; import androidx.test.filters.SmallTest; import androidx.test.filters.SmallTest; import androidx.test.runner.AndroidJUnit4; import androidx.test.runner.AndroidJUnit4; import com.android.bluetooth.flags.Flags; import org.junit.Rule; import org.junit.Rule; import org.junit.Test; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runner.RunWith; Loading @@ -33,22 +30,8 @@ import org.junit.runner.RunWith; @RunWith(AndroidJUnit4.class) @RunWith(AndroidJUnit4.class) public class ContentProfileErrorReportUtilsTest { 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 @Test public void tooFrequentErrorReportIsSkipped() { public void tooFrequentErrorReportIsSkipped() { mSetFlagsRule.enableFlags(Flags.FLAG_CONTENT_PROFILES_ERRORS_METRICS); // Set the last report time to the current time. // Set the last report time to the current time. long lastReportTimeMillisToSet = SystemClock.uptimeMillis(); long lastReportTimeMillisToSet = SystemClock.uptimeMillis(); ContentProfileErrorReportUtils.sLastReportTime = lastReportTimeMillisToSet; ContentProfileErrorReportUtils.sLastReportTime = lastReportTimeMillisToSet; Loading @@ -61,7 +44,6 @@ public class ContentProfileErrorReportUtilsTest { @Test @Test public void successfulReport() { public void successfulReport() { mSetFlagsRule.enableFlags(Flags.FLAG_CONTENT_PROFILES_ERRORS_METRICS); // Set the last report time to much earlier than the current time. // Set the last report time to much earlier than the current time. long lastReportTimeMillisToSet = long lastReportTimeMillisToSet = SystemClock.uptimeMillis() SystemClock.uptimeMillis() Loading system/bta/Android.bp +5 −0 Original line number Original line Diff line number Diff line Loading @@ -237,6 +237,7 @@ cc_test { ":TestMockBtif", ":TestMockBtif", ":TestMockDevice", ":TestMockDevice", ":TestMockMainShim", ":TestMockMainShim", ":TestMockMainShimEntry", ":TestMockStackA2dp", ":TestMockStackA2dp", ":TestMockStackAcl", ":TestMockStackAcl", ":TestMockStackAvct", ":TestMockStackAvct", Loading Loading @@ -333,6 +334,7 @@ cc_test { ":TestMockBtif", ":TestMockBtif", ":TestMockDevice", ":TestMockDevice", ":TestMockMainShim", ":TestMockMainShim", ":TestMockMainShimEntry", ":TestMockStackBtm", ":TestMockStackBtm", ":TestMockStackL2cap", ":TestMockStackL2cap", ":TestMockStackMetrics", ":TestMockStackMetrics", Loading Loading @@ -828,6 +830,7 @@ cc_test { ":TestCommonMockFunctions", ":TestCommonMockFunctions", ":TestMockBtaLeAudioHalVerifier", ":TestMockBtaLeAudioHalVerifier", ":TestMockMainShim", ":TestMockMainShim", ":TestMockMainShimEntry", ":TestMockStackL2cap", ":TestMockStackL2cap", ":TestStubOsi", ":TestStubOsi", "le_audio/audio_hal_client/audio_hal_client_test.cc", "le_audio/audio_hal_client/audio_hal_client_test.cc", Loading Loading @@ -921,6 +924,7 @@ cc_test { ":TestCommonMockFunctions", ":TestCommonMockFunctions", ":TestMockBtaLeAudioHalVerifier", ":TestMockBtaLeAudioHalVerifier", ":TestMockMainShim", ":TestMockMainShim", ":TestMockMainShimEntry", ":TestMockStackL2cap", ":TestMockStackL2cap", ":TestStubOsi", ":TestStubOsi", "gatt/database.cc", "gatt/database.cc", Loading Loading @@ -1225,6 +1229,7 @@ cc_test { ":TestMockBtif", ":TestMockBtif", ":TestMockDevice", ":TestMockDevice", ":TestMockMainShim", ":TestMockMainShim", ":TestMockMainShimEntry", ":TestMockOsi", ":TestMockOsi", ":TestMockStack", ":TestMockStack", "gatt/bta_gattc_queue.cc", "gatt/bta_gattc_queue.cc", Loading system/btif/Android.bp +2 −0 Original line number Original line Diff line number Diff line Loading @@ -613,6 +613,7 @@ cc_test { ":TestMockBtu", ":TestMockBtu", ":TestMockHci", ":TestMockHci", ":TestMockMainShim", ":TestMockMainShim", ":TestMockMainShimEntry", ":TestMockStack", ":TestMockStack", ":TestMockUdrv", ":TestMockUdrv", "test/btif_hh_test.cc", "test/btif_hh_test.cc", Loading Loading @@ -736,6 +737,7 @@ cc_test { ":TestMockBtu", ":TestMockBtu", ":TestMockHci", ":TestMockHci", ":TestMockMainShim", ":TestMockMainShim", ":TestMockMainShimEntry", ":TestMockStack", ":TestMockStack", ":TestMockUdrv", ":TestMockUdrv", "test/btif_core_test.cc", "test/btif_core_test.cc", Loading system/include/hardware/bt_common_types.h +10 −0 Original line number Original line Diff line number Diff line Loading @@ -128,4 +128,14 @@ struct MsftAdvMonitor { std::vector<MsftAdvMonitorPattern> patterns; std::vector<MsftAdvMonitorPattern> patterns; }; }; #if __has_include(<bluetooth/log.h>) #include <bluetooth/log.h> namespace fmt { template <> struct formatter<bt_gatt_db_attribute_type_t> : enum_formatter<bt_gatt_db_attribute_type_t> {}; } // namespace fmt #endif // __has_include(<bluetooth/log.h>) #endif /* ANDROID_INCLUDE_BT_COMMON_TYPES_H */ #endif /* ANDROID_INCLUDE_BT_COMMON_TYPES_H */ Loading
android/app/src/com/android/bluetooth/content_profiles/ContentProfileErrorReportUtils.java +1 −7 Original line number Original line Diff line number Diff line Loading @@ -21,12 +21,10 @@ import android.os.SystemClock; import android.util.Log; import android.util.Log; import com.android.bluetooth.BluetoothStatsLog; import com.android.bluetooth.BluetoothStatsLog; import com.android.bluetooth.flags.Flags; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.annotations.VisibleForTesting; /** /** * Utility method to report exceptions and error/warn logs in content profiles. Will be no-op if * Utility method to report exceptions and error/warn logs in content profiles. * {@link Flags#contentProfilesErrorsMetrics()} is not enabled. */ */ public class ContentProfileErrorReportUtils { public class ContentProfileErrorReportUtils { private static final String TAG = ContentProfileErrorReportUtils.class.getSimpleName(); 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 * @return true if successfully wrote the error, false otherwise */ */ public static synchronized boolean report(int profile, int fileNameEnum, int type, int tag) { public static synchronized boolean report(int profile, int fileNameEnum, int type, int tag) { if (!Flags.contentProfilesErrorsMetrics()) { return false; } if (isTooFrequentReport()) { if (isTooFrequentReport()) { Log.w( Log.w( TAG, TAG, Loading
android/app/tests/unit/src/com/android/bluetooth/content_profiles/ContentProfileErrorReportUtilsTest.java +0 −18 Original line number Original line 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 static com.google.common.truth.Truth.assertThat; import android.os.SystemClock; import android.os.SystemClock; import android.platform.test.flag.junit.SetFlagsRule; import androidx.test.filters.SmallTest; import androidx.test.filters.SmallTest; import androidx.test.runner.AndroidJUnit4; import androidx.test.runner.AndroidJUnit4; import com.android.bluetooth.flags.Flags; import org.junit.Rule; import org.junit.Rule; import org.junit.Test; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runner.RunWith; Loading @@ -33,22 +30,8 @@ import org.junit.runner.RunWith; @RunWith(AndroidJUnit4.class) @RunWith(AndroidJUnit4.class) public class ContentProfileErrorReportUtilsTest { 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 @Test public void tooFrequentErrorReportIsSkipped() { public void tooFrequentErrorReportIsSkipped() { mSetFlagsRule.enableFlags(Flags.FLAG_CONTENT_PROFILES_ERRORS_METRICS); // Set the last report time to the current time. // Set the last report time to the current time. long lastReportTimeMillisToSet = SystemClock.uptimeMillis(); long lastReportTimeMillisToSet = SystemClock.uptimeMillis(); ContentProfileErrorReportUtils.sLastReportTime = lastReportTimeMillisToSet; ContentProfileErrorReportUtils.sLastReportTime = lastReportTimeMillisToSet; Loading @@ -61,7 +44,6 @@ public class ContentProfileErrorReportUtilsTest { @Test @Test public void successfulReport() { public void successfulReport() { mSetFlagsRule.enableFlags(Flags.FLAG_CONTENT_PROFILES_ERRORS_METRICS); // Set the last report time to much earlier than the current time. // Set the last report time to much earlier than the current time. long lastReportTimeMillisToSet = long lastReportTimeMillisToSet = SystemClock.uptimeMillis() SystemClock.uptimeMillis() Loading
system/bta/Android.bp +5 −0 Original line number Original line Diff line number Diff line Loading @@ -237,6 +237,7 @@ cc_test { ":TestMockBtif", ":TestMockBtif", ":TestMockDevice", ":TestMockDevice", ":TestMockMainShim", ":TestMockMainShim", ":TestMockMainShimEntry", ":TestMockStackA2dp", ":TestMockStackA2dp", ":TestMockStackAcl", ":TestMockStackAcl", ":TestMockStackAvct", ":TestMockStackAvct", Loading Loading @@ -333,6 +334,7 @@ cc_test { ":TestMockBtif", ":TestMockBtif", ":TestMockDevice", ":TestMockDevice", ":TestMockMainShim", ":TestMockMainShim", ":TestMockMainShimEntry", ":TestMockStackBtm", ":TestMockStackBtm", ":TestMockStackL2cap", ":TestMockStackL2cap", ":TestMockStackMetrics", ":TestMockStackMetrics", Loading Loading @@ -828,6 +830,7 @@ cc_test { ":TestCommonMockFunctions", ":TestCommonMockFunctions", ":TestMockBtaLeAudioHalVerifier", ":TestMockBtaLeAudioHalVerifier", ":TestMockMainShim", ":TestMockMainShim", ":TestMockMainShimEntry", ":TestMockStackL2cap", ":TestMockStackL2cap", ":TestStubOsi", ":TestStubOsi", "le_audio/audio_hal_client/audio_hal_client_test.cc", "le_audio/audio_hal_client/audio_hal_client_test.cc", Loading Loading @@ -921,6 +924,7 @@ cc_test { ":TestCommonMockFunctions", ":TestCommonMockFunctions", ":TestMockBtaLeAudioHalVerifier", ":TestMockBtaLeAudioHalVerifier", ":TestMockMainShim", ":TestMockMainShim", ":TestMockMainShimEntry", ":TestMockStackL2cap", ":TestMockStackL2cap", ":TestStubOsi", ":TestStubOsi", "gatt/database.cc", "gatt/database.cc", Loading Loading @@ -1225,6 +1229,7 @@ cc_test { ":TestMockBtif", ":TestMockBtif", ":TestMockDevice", ":TestMockDevice", ":TestMockMainShim", ":TestMockMainShim", ":TestMockMainShimEntry", ":TestMockOsi", ":TestMockOsi", ":TestMockStack", ":TestMockStack", "gatt/bta_gattc_queue.cc", "gatt/bta_gattc_queue.cc", Loading
system/btif/Android.bp +2 −0 Original line number Original line Diff line number Diff line Loading @@ -613,6 +613,7 @@ cc_test { ":TestMockBtu", ":TestMockBtu", ":TestMockHci", ":TestMockHci", ":TestMockMainShim", ":TestMockMainShim", ":TestMockMainShimEntry", ":TestMockStack", ":TestMockStack", ":TestMockUdrv", ":TestMockUdrv", "test/btif_hh_test.cc", "test/btif_hh_test.cc", Loading Loading @@ -736,6 +737,7 @@ cc_test { ":TestMockBtu", ":TestMockBtu", ":TestMockHci", ":TestMockHci", ":TestMockMainShim", ":TestMockMainShim", ":TestMockMainShimEntry", ":TestMockStack", ":TestMockStack", ":TestMockUdrv", ":TestMockUdrv", "test/btif_core_test.cc", "test/btif_core_test.cc", Loading
system/include/hardware/bt_common_types.h +10 −0 Original line number Original line Diff line number Diff line Loading @@ -128,4 +128,14 @@ struct MsftAdvMonitor { std::vector<MsftAdvMonitorPattern> patterns; std::vector<MsftAdvMonitorPattern> patterns; }; }; #if __has_include(<bluetooth/log.h>) #include <bluetooth/log.h> namespace fmt { template <> struct formatter<bt_gatt_db_attribute_type_t> : enum_formatter<bt_gatt_db_attribute_type_t> {}; } // namespace fmt #endif // __has_include(<bluetooth/log.h>) #endif /* ANDROID_INCLUDE_BT_COMMON_TYPES_H */ #endif /* ANDROID_INCLUDE_BT_COMMON_TYPES_H */