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

Commit 68166c44 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 11456215 from 15fb936d to 24Q2-release

Change-Id: I42bf16d83397721f673a0b795e66c338a008efd6
parents c266e060 15fb936d
Loading
Loading
Loading
Loading
+1 −7
Original line number Original line Diff line number Diff line
@@ -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();
@@ -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,
+0 −18
Original line number Original line Diff line number Diff line
@@ -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;
@@ -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;
@@ -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()
+5 −0
Original line number Original line Diff line number Diff line
@@ -237,6 +237,7 @@ cc_test {
        ":TestMockBtif",
        ":TestMockBtif",
        ":TestMockDevice",
        ":TestMockDevice",
        ":TestMockMainShim",
        ":TestMockMainShim",
        ":TestMockMainShimEntry",
        ":TestMockStackA2dp",
        ":TestMockStackA2dp",
        ":TestMockStackAcl",
        ":TestMockStackAcl",
        ":TestMockStackAvct",
        ":TestMockStackAvct",
@@ -333,6 +334,7 @@ cc_test {
        ":TestMockBtif",
        ":TestMockBtif",
        ":TestMockDevice",
        ":TestMockDevice",
        ":TestMockMainShim",
        ":TestMockMainShim",
        ":TestMockMainShimEntry",
        ":TestMockStackBtm",
        ":TestMockStackBtm",
        ":TestMockStackL2cap",
        ":TestMockStackL2cap",
        ":TestMockStackMetrics",
        ":TestMockStackMetrics",
@@ -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",
@@ -921,6 +924,7 @@ cc_test {
        ":TestCommonMockFunctions",
        ":TestCommonMockFunctions",
        ":TestMockBtaLeAudioHalVerifier",
        ":TestMockBtaLeAudioHalVerifier",
        ":TestMockMainShim",
        ":TestMockMainShim",
        ":TestMockMainShimEntry",
        ":TestMockStackL2cap",
        ":TestMockStackL2cap",
        ":TestStubOsi",
        ":TestStubOsi",
        "gatt/database.cc",
        "gatt/database.cc",
@@ -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",
+2 −0
Original line number Original line Diff line number Diff line
@@ -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",
@@ -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",
+10 −0
Original line number Original line Diff line number Diff line
@@ -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