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

Commit fd446ea5 authored by David Duarte's avatar David Duarte Committed by Automerger Merge Worker
Browse files

Merge "Cache result of isInstrumentationTestMode" into main am: a0107bdf

parents dcc9efeb a0107bdf
Loading
Loading
Loading
Loading
+12 −4
Original line number Original line Diff line number Diff line
@@ -978,6 +978,9 @@ public final class Utils {
        return (int) (TimeUnit.MILLISECONDS.toMicros(milliseconds) / MICROS_PER_UNIT);
        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
     * 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
     * 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
     * @return true if in BluetoothInstrumentationTest, false otherwise
     */
     */
    public static boolean isInstrumentationTestMode() {
    public static boolean isInstrumentationTestMode() {
        if (!sIsInstrumentationTestModeCacheSet) {
            try {
            try {
            return Class.forName("com.android.bluetooth.FileSystemWriteTest") != null;
                sInstrumentationTestModeCache =
                        Class.forName("com.android.bluetooth.FileSystemWriteTest") != null;
            } catch (ClassNotFoundException exception) {
            } catch (ClassNotFoundException exception) {
            return false;
                sInstrumentationTestModeCache = false;
            }
            sIsInstrumentationTestModeCacheSet = true;
        }
        }
        return sInstrumentationTestModeCache;
    }
    }


    /**
    /**