Fixes SlogfTest#testIsLoggableFalse

Fixes: 223670638
Test: atest android.car.cts.builtin.util.SlogfTest#testIsLoggableFalse

Change-Id: Ie730e827294fbc05033f32339c5eb5369b36e59c
diff --git a/tests/tests/car_builtin/src/android/car/cts/builtin/util/LogcatHelper.java b/tests/tests/car_builtin/src/android/car/cts/builtin/util/LogcatHelper.java
index 39b9895..4293f20 100644
--- a/tests/tests/car_builtin/src/android/car/cts/builtin/util/LogcatHelper.java
+++ b/tests/tests/car_builtin/src/android/car/cts/builtin/util/LogcatHelper.java
@@ -19,6 +19,7 @@
 import static org.junit.Assert.fail;
 
 import android.app.UiAutomation;
+import android.car.cts.builtin.util.LogcatHelper.Level;
 import android.os.ParcelFileDescriptor;
 import android.os.SystemClock;
 import android.util.Log;
@@ -161,4 +162,11 @@
         }
         SystemUtil.runShellCommand("logcat -b all -c");
     }
+
+    /**
+     * Sets the log level of the given tag.
+     */
+    public static void setLogLevel(String tag, Level level) {
+        SystemUtil.runShellCommand("setprop log.tag." + tag + " " + level.getValue());
+    }
 }
diff --git a/tests/tests/car_builtin/src/android/car/cts/builtin/util/SlogfTest.java b/tests/tests/car_builtin/src/android/car/cts/builtin/util/SlogfTest.java
index 8eeecc4..1740eb5 100644
--- a/tests/tests/car_builtin/src/android/car/cts/builtin/util/SlogfTest.java
+++ b/tests/tests/car_builtin/src/android/car/cts/builtin/util/SlogfTest.java
@@ -22,6 +22,7 @@
 import static android.car.cts.builtin.util.LogcatHelper.Level.INFO;
 import static android.car.cts.builtin.util.LogcatHelper.Level.VERBOSE;
 import static android.car.cts.builtin.util.LogcatHelper.Level.WARN;
+import static android.car.cts.builtin.util.LogcatHelper.clearLog;
 
 import static com.google.common.truth.Truth.assertThat;
 
@@ -29,16 +30,13 @@
 import android.car.cts.builtin.util.LogcatHelper.Level;
 import android.util.Log;
 
-import com.android.compatibility.common.util.SystemUtil;
-
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 
 public final class SlogfTest {
     private static final String TAG = SlogfTest.class.getSimpleName();
-    // Comes from Slogf.CAR_TEST_TAG;
-    private static final String CAR_TEST_TAG = "CAR.TEST";
+
     private static final int TIMEOUT_MS = 10_000;
     // All Slogf would be logged to system buffer.
     private static final LogcatHelper.Buffer BUFFER = LogcatHelper.Buffer.SYSTEM;
@@ -376,15 +374,24 @@
     @Test
     public void testIsLoggableFalse() throws Exception {
         setLogLevel(ERROR);
+        setCarTestTagLogLevel(ASSERT);
 
         assertThat(Slogf.isLoggable(TAG, Log.VERBOSE)).isFalse();
     }
 
     @Test
+    public void testIsLoggableFalse_withCarTestTagEnabled() throws Exception {
+        setLogLevel(ERROR);
+        setCarTestTagLogLevel(VERBOSE);
+
+        assertThat(Slogf.isLoggable(TAG, Log.VERBOSE)).isTrue();
+    }
+
+    @Test
     public void testSlogfIsfLoggableWorksSameAsLogIsLoggable() throws Exception {
         setLogLevel(INFO);
         // Emulate the tag as if it's not in the car tests.
-        setLogLevel(CAR_TEST_TAG, ASSERT);
+        setCarTestTagLogLevel(ASSERT);
 
         assertThat(Log.isLoggable(TAG, Log.DEBUG)).isFalse();
         assertThat(Slogf.isLoggable(TAG, Log.DEBUG)).isFalse();
@@ -401,16 +408,13 @@
         assertThat(Slogf.isLoggable(TAG, Log.DEBUG)).isTrue();
     }
 
-    private void clearLog() {
-        LogcatHelper.clearLog();
-    }
-
     private void setLogLevel(Level level) {
-        setLogLevel(TAG, level);
+        LogcatHelper.setLogLevel(TAG, level);
     }
 
-    private void setLogLevel(String tag, Level level) {
-        SystemUtil.runShellCommand("setprop log.tag." + tag + " " + level.getValue());
+    private void setCarTestTagLogLevel(Level level) {
+        // CAR.TEST Comes from Slogf.CAR_TEST_TAG;
+        LogcatHelper.setLogLevel("CAR.TEST", level);
     }
 
     private void assertNoLogcatMessage(Level level, String format, Object... args)