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

Commit a0107bdf authored by David Duarte's avatar David Duarte Committed by Gerrit Code Review
Browse files

Merge "Cache result of isInstrumentationTestMode" into main

parents 8da0cec9 a8d3d870
Loading
Loading
Loading
Loading
+12 −4
Original line number Diff line number Diff line
@@ -978,6 +978,9 @@ public final class Utils {
        return (int) (TimeUnit.MILLISECONDS.toMicros(milliseconds) / MICROS_PER_UNIT);
    }

    private static boolean sIsInstrumentationTestModeCacheSet = false;
    private static boolean sInstrumentationTestModeCache = false;

    /**
     * Check if we are running in BluetoothInstrumentationTest context by trying to load
     * com.android.bluetooth.FileSystemWriteTest. If we are not in Instrumentation test mode, this
@@ -988,11 +991,16 @@ public final class Utils {
     * @return true if in BluetoothInstrumentationTest, false otherwise
     */
    public static boolean isInstrumentationTestMode() {
        if (!sIsInstrumentationTestModeCacheSet) {
            try {
            return Class.forName("com.android.bluetooth.FileSystemWriteTest") != null;
                sInstrumentationTestModeCache =
                        Class.forName("com.android.bluetooth.FileSystemWriteTest") != null;
            } catch (ClassNotFoundException exception) {
            return false;
                sInstrumentationTestModeCache = false;
            }
            sIsInstrumentationTestModeCacheSet = true;
        }
        return sInstrumentationTestModeCache;
    }

    /**